Conversation
9475d37 to
d4d74a4
Compare
bbec96c to
999cbdb
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 999cbdb177
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return Ok(()); | ||
| } | ||
|
|
||
| if let Some(ignored_path) = ignored_toml_value_field::<ConfigToml>(cli_overrides_layer.clone()) |
There was a problem hiding this comment.
Validate CLI overrides with a base path before strict checks
validate_cli_overrides_strictly_if_requested calls ignored_toml_value_field directly on the override layer, but that helper returns None whenever deserialization errors. Because no AbsolutePathBufGuard is set here, any valid relative-path override for an AbsolutePathBuf field (for example model_instructions_file=...) can cause deserialization to fail, which skips unknown-field detection entirely for the same -c payload. In --strict-config mode this lets unknown non-feature keys pass when combined with such a relative-path override, defeating the strict override validation.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in 246051aa7613. validate_cli_overrides_strictly_if_requested now receives the CLI override base directory and installs AbsolutePathBufGuard before running the strict serde/ignored-field check, so relative-path overrides no longer mask unknown -c keys. I also added strict_config_rejects_unknown_cli_override_key_with_relative_path_override to cover model_instructions_file = "instructions.md" combined with an unknown override.
Why
Codex intentionally ignores unknown
config.tomlfields by default so older and newer config files keep working across versions. That leniency also makes typo detection hard because misspelled or misplaced keys disappear silently. This adds an opt-in strict config mode so users and tooling can fail fast on unrecognized config fields without changing the default behavior.This feature is possible because
serde_ignoredexposes the exact signal Codex needs: it can run ordinary Serde deserialization while recording fields Serde would otherwise ignore. That avoids requiring#[serde(deny_unknown_fields)]across every config type and lets strict config validation stay opt-in around the existing permissive model.What Changed
User-facing strict mode
--strict-configflag.-c/--configCLI override layers when strict config mode is enabled.Validation implementation
serde_ignored-based validation forConfigTomlincodex-rs/config/src/strict_config.rs.serde_ignoredwithserde_path_to_errorso strict mode preserves typed config error paths while also collecting fields Serde would otherwise ignore.[features]keys, including keys that are normally captured byFeaturesToml's flattened boolean map.Config loading shape
ConfigBuilder::strict_config(...)for top-level callers andConfigLoadOptionsplumbing for lower-level load sites.TomlValue; for actual config sources, the loader reads the file/string once, parses it once, and validates that same parsed value.-ckeys are still reported when another override contains a relative path.strict_config.rs, leavingdiagnostics.rsfocused on source/range mapping and formatting.Coverage
[features]keys, source-location reporting for unknown keys, non-file managed preference source names, and typed-error precedence over ignored-field reporting.--enable, invalid--disable, and unknown-coverrides still error when--strict-configis present, including compound-looking feature names such asmulti_agent_v2.subagent_usage_hint_text.--strict-config -c features.foo=trueso unknown feature keys are rejected even though[features]uses a flattened map internally.-ckeys combined with relative path overrides such asmodel_instructions_file=instructions.md.Example Usage
Run Codex with strict config validation enabled:
Strict config mode can also be used with subcommands that load
config.toml:For example, if
~/.codex/config.tomlcontains a typo in a key name:then
codex --strict-configreports the misspelled key instead of silently ignoring it. The path is shortened to~here for readability:Without
--strict-config, Codex keeps the existing permissive behavior and ignores the unknown key.Strict config mode also validates ad-hoc
-c/--configoverrides:Strict config mode also composes with CLI feature toggles. Invalid feature names are rejected, including values that look like nested config paths:
Verification
cargo test -p codex-configcargo test -p codex-config strict_configcargo test -p codex-core config_loader_tests::strict_configcargo test -p codex-cli strict_configjust fix -p codex-config -p codex-corejust fix -p codex-config -p codex-clijust argument-comment-lintThe
codex-clistrict_configtests cover invalid--enable, invalid--disable, the compoundmulti_agent_v2.subagent_usage_hint_textcase, and the--strict-config -c foo=barpath. Thecodex-coreconfig loader tests cover--strict-config -c features.foo=trueand unknown-ckeys combined with relative path overrides.Documentation
The Codex CLI docs on developers.openai.com/codex should mention
--strict-configas an opt-in validation mode forconfig.tomlonce this ships.