mirror of
https://github.com/openai/codex.git
synced 2026-12-06 01:10:58 +00:00
Deprecate --config and limit it to legacy keys (#65357)
## What changed Mark `-c` and `--config` as deprecated in CLI help and direct users to dedicated flags or `config.toml`. Check explicit overrides against a fixed list of legacy keys before expanding dedicated flags. Reject unknown keys even without `--strict-config`, including keys inside inline tables and arrays of tables. The `app-server` subcommand skips the legacy-key check. Preserve the meaning of positional `features.guardianv3.housekeeper` overrides by mapping the legacy positions to named fields. ## Testing Cover unknown nested keys and verify that `codex-exec resume` checks overrides on both sides of the subcommand while preserving their order. Test that a legacy positional housekeeper override still sets `batch_timeout_ms`. GitOrigin-RevId: ae13d976ad5e13068096c0f2548fdf0ab35535f3
This commit is contained in:
committed by
copyberry
parent
3a6ecd7366
commit
7aa5d4ea3a
@@ -952,11 +952,11 @@ async fn run_debug_app_server_command(cmd: DebugAppServerCommand) -> anyhow::Res
|
||||
|
||||
#[derive(Debug, Default, Parser, Clone)]
|
||||
struct FeatureToggles {
|
||||
/// Enable a feature (repeatable). Equivalent to `-c features.<name>=true`.
|
||||
/// Enable a feature (repeatable).
|
||||
#[arg(long = "enable", value_name = "FEATURE", action = clap::ArgAction::Append, global = true)]
|
||||
enable: Vec<String>,
|
||||
|
||||
/// Disable a feature (repeatable). Equivalent to `-c features.<name>=false`.
|
||||
/// Disable a feature (repeatable).
|
||||
#[arg(long = "disable", value_name = "FEATURE", action = clap::ArgAction::Append, global = true)]
|
||||
disable: Vec<String>,
|
||||
}
|
||||
@@ -1086,6 +1086,11 @@ async fn dispatch_cli(
|
||||
anyhow::bail!("Cloud does not support fork");
|
||||
}
|
||||
reject_unsupported_worktree_for_subcommand(cli.interactive.shared.worktree, &cli.subcommand)?;
|
||||
if !matches!(&cli.subcommand, Some(Subcommand::AppServer(_))) {
|
||||
cli.config_overrides
|
||||
.legacy_keys()
|
||||
.map_err(anyhow::Error::msg)?;
|
||||
}
|
||||
config_override_args::expand_flags(&mut cli)?;
|
||||
let MultitoolCli {
|
||||
config_overrides: mut root_config_overrides,
|
||||
|
||||
@@ -60,7 +60,7 @@ fn configure_help(command: Command) -> Command {
|
||||
let interactive = TuiCli::command();
|
||||
command.mut_args(|arg| {
|
||||
if arg.get_long() == Some("config") {
|
||||
arg.long_help(None).help("Override a startup configuration value (key=value). Queued messages use the thread's model.")
|
||||
arg.long_help(None).help("Deprecated. Override a legacy startup configuration key. Queued messages use the thread's model.")
|
||||
} else if !restricted_options(&interactive).any(|shared| shared.get_id() == arg.get_id()) {
|
||||
arg
|
||||
} else if arg.get_long() == Some("cd") {
|
||||
|
||||
+6
-10
@@ -12,25 +12,21 @@ Commands:
|
||||
|
||||
Options:
|
||||
-c, --config <key=value>
|
||||
Override a configuration value that would otherwise be loaded from
|
||||
`~/.codex/config.toml`. Use a dotted path (`foo.bar.baz`) to override
|
||||
nested values. The `value` portion is parsed as TOML. If it fails to
|
||||
parse as TOML, the raw string is used as a literal.
|
||||
Deprecated. Override a legacy configuration key.
|
||||
|
||||
Examples: - `-c model="o3"` - `-c
|
||||
'sandbox_permissions=["disk-full-read-access"]'` - `-c
|
||||
shell_environment_policy.inherit=all`
|
||||
Prefer a dedicated flag or set the key in `config.toml`. Use dotted
|
||||
paths for nested keys. Values are parsed as TOML or, if parsing fails,
|
||||
as literal strings.
|
||||
|
||||
--enable <FEATURE>
|
||||
Enable a feature (repeatable). Equivalent to `-c features.<name>=true`
|
||||
Enable a feature (repeatable)
|
||||
|
||||
--strict-config
|
||||
Error out when config.toml contains fields that are not recognized by
|
||||
this version of Codex
|
||||
|
||||
--disable <FEATURE>
|
||||
Disable a feature (repeatable). Equivalent to `-c
|
||||
features.<name>=false`
|
||||
Disable a feature (repeatable)
|
||||
|
||||
--linux-sandbox-pid-namespace <MODE>
|
||||
Linux PID namespace: isolate (default) or inherit. Inherit allows
|
||||
|
||||
@@ -26,19 +26,30 @@ fn codex_command(codex_home: &Path) -> Result<assert_cmd::Command> {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn strict_config_rejects_unknown_config_override() -> Result<()> {
|
||||
fn config_overrides_reject_new_fields_even_without_strict_config() -> Result<()> {
|
||||
for (config_override, ignored_path) in [
|
||||
("foo=bar", "foo"),
|
||||
("tui.bogus_key_xyz=1", "tui.bogus_key_xyz"),
|
||||
("tui={bogus_key_xyz=1}", "tui.bogus_key_xyz"),
|
||||
(
|
||||
"skills.config=[{future_key=true}]",
|
||||
"skills.config.future_key",
|
||||
),
|
||||
] {
|
||||
let codex_home = TempDir::new()?;
|
||||
let mut cmd = codex_command(codex_home.path())?;
|
||||
cmd.args(["--strict-config", "-c", config_override, "exec", "hello"])
|
||||
.assert()
|
||||
.failure()
|
||||
.stderr(contains(format!(
|
||||
"unknown configuration field `{ignored_path}`"
|
||||
)));
|
||||
cmd.args([
|
||||
"-c",
|
||||
config_override,
|
||||
"exec",
|
||||
"--config=model=example",
|
||||
"hello",
|
||||
])
|
||||
.assert()
|
||||
.failure()
|
||||
.stderr(contains(format!(
|
||||
"unknown configuration field `{ignored_path}`"
|
||||
)));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user