fix: reject legacy profile selectors (#24059)

## Why

`--profile` now selects `<name>.config.toml`, so the legacy `profile`
selector should not be reintroduced through config write or MCP tool
paths. A matching legacy selector in base user config also needs the
same migration guard as a matching legacy `[profiles.<name>]` table so
profile loading fails with one clear migration error instead of mixing
the old and new profile models.

## What

- reject non-null app-server config writes to the top-level legacy
`profile` selector
- make `--profile <name>` reject base user config that still selects the
same legacy `profile = "<name>"` value, alongside the existing matching
legacy profile-table guard
- reject removed MCP `codex` tool fields such as `profile` by denying
unknown tool-call parameters and exposing that restriction in the
generated schema
- add regression coverage for the app-server write paths, config loader
guard, and MCP tool input/schema behavior

## Verification

- targeted regression tests cover the new app-server, config loader, and
MCP rejection paths
This commit is contained in:
jif-oai authored and GitHub committed 2026-05-22 13:19:47 +02:00
1 parent 47476e8a8a
commit 932f72c225
5 files changed
+180 -16

No files matched your search

+55
View File
@@ -137,6 +137,61 @@ model = "gpt-work"
);
}
#[tokio::test]
async fn profile_v2_rejects_matching_legacy_profile_selector_in_base_user_config() {
let tmp = tempdir().expect("tempdir");
let selected_config = tmp.path().join("work.config.toml");
std::fs::write(
tmp.path().join(CONFIG_TOML_FILE),
r#"
profile = "work"
model = "gpt-main"
"#,
)
.expect("write default user config");
std::fs::write(&selected_config, r#"model = "gpt-work-v2""#)
.expect("write selected user config");
let mut overrides = LoaderOverrides::without_managed_config_for_tests();
overrides.user_config_path = Some(AbsolutePathBuf::resolve_path_against_base(
"work.config.toml",
tmp.path(),
));
overrides.user_config_profile = Some("work".parse().expect("profile-v2 name"));
let err = load_config_layers_state(
&TestFileSystem,
tmp.path(),
/*cwd*/ None,
&[],
overrides,
CloudRequirementsLoader::default(),
&crate::NoopThreadConfigLoader,
)
.await
.expect_err("profile-v2 should reject a matching legacy profile selector");
assert_eq!(
err.kind(),
io::ErrorKind::InvalidData,
"a matching legacy profile selector should be a hard config error"
);
let message = err.to_string();
assert!(
message.contains("--profile `work` cannot be used"),
"unexpected error message: {message}"
);
assert!(
message.contains("profile = \"work\""),
"unexpected error message: {message}"
);
assert!(
message.contains("work.config.toml"),
"unexpected error message: {message}"
);
}
#[tokio::test]
async fn profile_v2_allows_unrelated_legacy_profiles_in_base_user_config() {
let tmp = tempdir().expect("tempdir");