{"record":{"id":"088106e92113f7aa","repo":"openai/codex","slug":"generated-skill-tool-schema-should-serialize-err","errorCode":null,"errorMessage":"generated skill tool schema should serialize: {err}","messagePattern":"generated skill tool schema should serialize: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"codex-rs/ext/skills/src/tools/schema.rs","lineNumber":23,"sourceCode":"\npub(super) fn input_schema_for<T: JsonSchema>() -> Value {\n    schema_for::<T>(/*option_add_null_type*/ false)\n}\n\npub(super) fn output_schema_for<T: JsonSchema>() -> Value {\n    schema_for::<T>(/*option_add_null_type*/ true)\n}\n\nfn schema_for<T: JsonSchema>(option_add_null_type: bool) -> Value {\n    let schema = SchemaSettings::draft2019_09()\n        .with(|settings| {\n            settings.inline_subschemas = true;\n            settings.option_add_null_type = option_add_null_type;\n        })\n        .into_generator()\n        .into_root_schema_for::<T>();\n    let schema_value = serde_json::to_value(schema)\n        .unwrap_or_else(|err| panic!(\"generated skill tool schema should serialize: {err}\"));\n    let Value::Object(mut schema_object) = schema_value else {\n        unreachable!(\"root tool schema must be an object\");\n    };\n\n    let mut tool_schema = Map::new();\n    for key in [\n        \"properties\",\n        \"required\",\n        \"type\",\n        \"additionalProperties\",\n        \"$defs\",\n        \"definitions\",\n    ] {\n        if let Some(value) = schema_object.remove(key) {\n            tool_schema.insert(key.to_string(), value);\n        }\n    }\n    Value::Object(tool_schema)","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/ext/skills/src/tools/schema.rs#L5-L41","documentation":"This panic sits in schema_for (codex-rs/ext/skills/src/tools/schema.rs:22-23): after schemars generates a root JSON Schema, serde_json::to_value serializes it, and a serialization failure aborts with this message. It is an internal-invariant panic - schemars' Schema type serializes to JSON by construction, so with released crates this path is effectively unreachable. Encountering it points at a broken environment (corrupted build artifacts, or a patched/forked schemars or serde_json in the dependency graph) rather than any caller mistake.","triggerScenarios":"serde_json::to_value fails on a schemars root schema - the only realistic causes are a dependency fork/patch emitting non-serializable content or corrupted incremental-build artifacts. Fires at skill tool registration time, deterministically per build.","commonSituations":"A [patch] entry or git dependency swapping schemars/serde_json for a modified version; a stale or corrupt target/ directory after an interrupted build; practically never on a clean stock build.","solutions":["Run cargo clean and rebuild to clear corrupted incremental artifacts","Check Cargo.toml/Cargo.lock for [patch] sections or forked schemars/serde_json versions; pin the stock crates","If it reproduces on a clean build with stock dependencies, capture the {err} payload and file a codex-rs issue - it is a library-level bug"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"let built = std::panic::catch_unwind(|| {\n    skill_function_tool::<MyArgs, MyOut>(\"my_tool\", \"desc\")\n});\nif built.is_err() {\n    tracing::error!(\"skill schema generation panicked; skipping tool\");\n}","preventionTips":["Treat this panic as an environment signal - cargo clean before debugging code","Keep schemars and serde_json unpatched and single-sourced in Cargo.lock","Wrap skill tool registration in catch_unwind when it runs inside a long-lived host process"],"tags":["skills","json-schema","serde","panic","build-corruption","rust"],"backgroundTag":"json-schema-generation-failed","analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}