Skip to content

fix(app-server): clear_path treats absent intermediate tables as a no-op#1

Open
sumaiazaman wants to merge 1 commit into
mainfrom
fix/config-clear-missing-nested-path
Open

fix(app-server): clear_path treats absent intermediate tables as a no-op#1
sumaiazaman wants to merge 1 commit into
mainfrom
fix/config-clear-missing-nested-path

Conversation

@sumaiazaman

Copy link
Copy Markdown
Owner

Summary

Fixes openai#20145.

config/value/write with value: null is the API contract for clearing/unsetting a config key. When the path points to a nested key whose parent table does not yet exist in config.toml (e.g. clearing features.personality from an empty file), clear_path was returning MergeError::PathNotFound which surfaces to callers as configPathNotFound / Path not found.

The correct behaviour is to treat it as an idempotent no-op — the value is already absent, so the clear succeeds with no file change.

Root cause — two arms in clear_path that encounter a missing intermediate table:

// before
TomlValue::Table(table) => {
    current = table.get_mut(segment).ok_or(MergeError::PathNotFound)?;
}
_ => return Err(MergeError::PathNotFound),

Fix — return Ok(false) (value unchanged) instead of propagating an error:

// after
TomlValue::Table(table) => match table.get_mut(segment) {
    Some(next) => current = next,
    None => return Ok(false),
},
_ => return Ok(false),

The as_table_mut() guard at the end of the function is updated consistently for the same reason.

Changes

  • codex-rs/app-server/src/config_manager_service.rs — fix clear_path
  • codex-rs/app-server/src/config_manager_service_tests.rs — regression test clear_missing_nested_config_is_noop

Test plan

  • New test clear_missing_nested_config_is_noop reproduces the reported failure before the fix and passes after
  • Existing write_value_* tests continue to pass
  • cargo test -p codex-app-server green

… tables

When config/value/write is called with a null value to clear a nested
key (e.g. "features.personality") and an intermediate parent table
(e.g. [features]) does not yet exist in config.toml, clear_path was
returning MergeError::PathNotFound instead of treating the operation as
an idempotent no-op.

Clearing an already-absent value should succeed silently. Change the
absent-parent arms in clear_path to return Ok(false) so callers do not
need to distinguish "value exists" from "value is already unset" before
issuing a clear.

Fixes openai#20145
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

app-server config/value/write returns configPathNotFound when clearing an unset nested config value

1 participant