From cfbea9b3fbc83bd2bc68a75735b40c3843a0fe48 Mon Sep 17 00:00:00 2001 From: Bob Lee Date: Tue, 10 Nov 2026 11:15:41 +0800 Subject: [PATCH 1/2] 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. --- .../tools/openbitfun_control_config.rs | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/crates/assembly/core/src/agentic/tools/openbitfun_control_config.rs b/src/crates/assembly/core/src/agentic/tools/openbitfun_control_config.rs index d6ec3534db..0859e5fb61 100644 --- a/src/crates/assembly/core/src/agentic/tools/openbitfun_control_config.rs +++ b/src/crates/assembly/core/src/agentic/tools/openbitfun_control_config.rs @@ -520,10 +520,14 @@ pub async fn apply_legacy_config_mutation_with_model_snapshot( .await .map_err(|error| error.to_string())? }; - let effective_value = config_service - .get_config(Some(path)) - .await - .map_err(|error| error.to_string())?; + // Fields that keep legacy files unchanged omit their default value when + // serialized, so a successful write of that default leaves no leaf to + // read back. Report it as null, matching an optional read of the path. + let effective_value = match config_service.get_config(Some(path)).await { + Ok(value) => value, + Err(crate::util::errors::OpenBitFunError::NotFound(_)) => Value::Null, + Err(error) => return Err(error.to_string()), + }; Ok(AppliedLegacyProductConfig { changed, changed_path: path.to_string(), @@ -739,6 +743,29 @@ mod tests { ); } + #[tokio::test] + async fn legacy_mutation_accepts_writes_of_an_omitted_default() { + let (service, _dir) = test_service("legacy-omitted-default").await; + let path = "app.flow_chat.send_during_turn"; + + let queued = apply_legacy_config_mutation(&service, path, json!("queue")) + .await + .expect("queue write"); + assert!(queued.changed); + assert_eq!(queued.effective_value, json!("queue")); + + let immediate = apply_legacy_config_mutation(&service, path, json!("immediate")) + .await + .expect("writing the omitted default must not fail its read-back"); + assert!(immediate.changed); + assert_eq!(immediate.effective_value, Value::Null); + let config: GlobalConfig = service.get_config(None).await.unwrap(); + assert_eq!( + serde_json::to_value(config.app.flow_chat.send_during_turn).unwrap(), + json!("immediate") + ); + } + #[tokio::test] async fn config_handler_round_trips_through_the_shared_service() { let (service, _dir) = test_service("product-control-round-trip").await; From 76e5a9d40e6f19641b0a7096985d488f145a9aa1 Mon Sep 17 00:00:00 2001 From: Bob Lee Date: Tue, 10 Nov 2026 11:22:35 +0800 Subject: [PATCH 2/2] fix(config): keep failing legacy writes the config silently drops Serde ignores unknown fields, so a legacy write to a misspelled path, or to a field this host does not know yet, leaves the config unchanged and used to fail on its read-back. Only report a missing leaf as null when the write actually changed the config, which is the case when restoring an omitted default or clearing an optional value. --- .../tools/openbitfun_control_config.rs | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/crates/assembly/core/src/agentic/tools/openbitfun_control_config.rs b/src/crates/assembly/core/src/agentic/tools/openbitfun_control_config.rs index 0859e5fb61..adcc1ff8c5 100644 --- a/src/crates/assembly/core/src/agentic/tools/openbitfun_control_config.rs +++ b/src/crates/assembly/core/src/agentic/tools/openbitfun_control_config.rs @@ -520,12 +520,14 @@ pub async fn apply_legacy_config_mutation_with_model_snapshot( .await .map_err(|error| error.to_string())? }; - // Fields that keep legacy files unchanged omit their default value when - // serialized, so a successful write of that default leaves no leaf to - // read back. Report it as null, matching an optional read of the path. + // Some fields omit their default (or `None`) when serialized so legacy + // files stay unchanged, so a write that restores it leaves no leaf to read + // back. Report that as null, matching an optional read of the path. Only a + // write that changed the config qualifies: serde drops unknown fields + // without changing anything, and those writes must keep failing loudly. let effective_value = match config_service.get_config(Some(path)).await { Ok(value) => value, - Err(crate::util::errors::OpenBitFunError::NotFound(_)) => Value::Null, + Err(crate::util::errors::OpenBitFunError::NotFound(_)) if changed => Value::Null, Err(error) => return Err(error.to_string()), }; Ok(AppliedLegacyProductConfig { @@ -764,6 +766,30 @@ mod tests { serde_json::to_value(config.app.flow_chat.send_during_turn).unwrap(), json!("immediate") ); + + let cleared_path = "app.flow_chat.last_mode_id"; + apply_legacy_config_mutation(&service, cleared_path, json!("Plan")) + .await + .expect("optional write"); + let cleared = apply_legacy_config_mutation(&service, cleared_path, Value::Null) + .await + .expect("clearing an optional leaf must not fail its read-back"); + assert!(cleared.changed); + assert_eq!(cleared.effective_value, Value::Null); + } + + #[tokio::test] + async fn legacy_mutation_still_rejects_paths_the_config_drops() { + let (service, _dir) = test_service("legacy-unknown-path").await; + + let error = apply_legacy_config_mutation( + &service, + "app.flow_chat.not_a_known_field", + json!("queue"), + ) + .await + .expect_err("a write that serde drops must not report success"); + assert!(error.contains("not found"), "{error}"); } #[tokio::test]