Skip to content

Commit cfbea9b

Browse files
committed
fix(config): accept GUI writes that restore an omitted default
Settings such as app.flow_chat.send_during_turn omit their default value when serialized so legacy config files stay unchanged. Writing that default through the legacy GUI config path succeeded, but the follow-up read-back of the effective value failed with "Config path not found", so the GUI reported a save failure and kept showing the old value. Report the omitted default as null, matching an optional read of the path, and keep failing on any other read error.
1 parent 16a3438 commit cfbea9b

1 file changed

Lines changed: 31 additions & 4 deletions

File tree

‎src/crates/assembly/core/src/agentic/tools/openbitfun_control_config.rs‎

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,10 +520,14 @@ pub async fn apply_legacy_config_mutation_with_model_snapshot(
520520
.await
521521
.map_err(|error| error.to_string())?
522522
};
523-
let effective_value = config_service
524-
.get_config(Some(path))
525-
.await
526-
.map_err(|error| error.to_string())?;
523+
// Fields that keep legacy files unchanged omit their default value when
524+
// serialized, so a successful write of that default leaves no leaf to
525+
// read back. Report it as null, matching an optional read of the path.
526+
let effective_value = match config_service.get_config(Some(path)).await {
527+
Ok(value) => value,
528+
Err(crate::util::errors::OpenBitFunError::NotFound(_)) => Value::Null,
529+
Err(error) => return Err(error.to_string()),
530+
};
527531
Ok(AppliedLegacyProductConfig {
528532
changed,
529533
changed_path: path.to_string(),
@@ -739,6 +743,29 @@ mod tests {
739743
);
740744
}
741745

746+
#[tokio::test]
747+
async fn legacy_mutation_accepts_writes_of_an_omitted_default() {
748+
let (service, _dir) = test_service("legacy-omitted-default").await;
749+
let path = "app.flow_chat.send_during_turn";
750+
751+
let queued = apply_legacy_config_mutation(&service, path, json!("queue"))
752+
.await
753+
.expect("queue write");
754+
assert!(queued.changed);
755+
assert_eq!(queued.effective_value, json!("queue"));
756+
757+
let immediate = apply_legacy_config_mutation(&service, path, json!("immediate"))
758+
.await
759+
.expect("writing the omitted default must not fail its read-back");
760+
assert!(immediate.changed);
761+
assert_eq!(immediate.effective_value, Value::Null);
762+
let config: GlobalConfig = service.get_config(None).await.unwrap();
763+
assert_eq!(
764+
serde_json::to_value(config.app.flow_chat.send_during_turn).unwrap(),
765+
json!("immediate")
766+
);
767+
}
768+
742769
#[tokio::test]
743770
async fn config_handler_round_trips_through_the_shared_service() {
744771
let (service, _dir) = test_service("product-control-round-trip").await;

0 commit comments

Comments
 (0)