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

+25 -2
View File
@@ -20,7 +20,8 @@ use std::sync::Arc;
/// Client-supplied configuration for a `codex` tool-call.
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, Default)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "kebab-case", deny_unknown_fields)]
#[schemars(deny_unknown_fields)]
pub struct CodexToolCallParam {
/// The *initial user prompt* to start the Codex conversation.
pub prompt: String,
@@ -271,7 +272,14 @@ fn create_tool_input_schema(
// in case any `$ref` leaks into the generated schema (even though we try
// to inline subschemas).
let mut input_schema = JsonObject::new();
for key in ["properties", "required", "type", "$defs", "definitions"] {
for key in [
"additionalProperties",
"properties",
"required",
"type",
"$defs",
"definitions",
] {
if let Some(value) = schema_object.remove(key) {
input_schema.insert(key.to_string(), value);
}
@@ -303,6 +311,7 @@ mod tests {
let expected_tool_json = serde_json::json!({
"description": "Run a Codex session. Accepts configuration parameters matching the Codex Config struct.",
"inputSchema": {
"additionalProperties": false,
"properties": {
"approval-policy": {
"description": "Approval policy for shell commands generated by the model: `untrusted`, `on-failure`, `on-request`, `never`.",
@@ -379,6 +388,20 @@ mod tests {
assert_eq!(expected_tool_json, tool_json);
}
#[test]
fn codex_tool_call_param_rejects_removed_profile_field() {
let err = serde_json::from_value::<CodexToolCallParam>(serde_json::json!({
"prompt": "hello",
"profile": "work"
}))
.expect_err("removed profile field should fail");
assert!(
err.to_string().contains("unknown field `profile`"),
"unexpected error: {err}"
);
}
#[test]
fn verify_codex_tool_reply_json_schema() {
let tool = create_tool_for_codex_tool_call_reply_param();