openai/codex · error · anyhow::Error

schema definition collision in

Error message

schema definition collision in {location}: {name} (existing title: {existing_title}, new title: {new_title}); use #[schemars(rename = "...")] to rename one of the conflicting schema definitions

What it means

Error "schema definition collision in {location}: {name} (existing title: {existing_title}, new title: {new_title}); use #[schemars(rename = "...")] to rename one of the conflicting schema definitions" thrown in openai/codex.

Solutions

  1. Add `#[schemars(rename = "...")]` to one of the two Rust types whose schemas collide under the same definition name
  2. Rename the conflicting type at the Rust level so the generated schema names differ
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at codex-rs/app-server-protocol/src/export.rs:1317 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/9747414b201cbfd4. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/app-server-protocol/src/export.rs:1317

    definitions: &mut Map<String, Value>,
    name: String,
    schema: Value,
    location: &str,
) -> Result<()> {
    if let Some(existing) = definitions.get(&name) {
        if existing == &schema {
            return Ok(());
        }

        let existing_title = existing
            .get("title")
            .and_then(Value::as_str)
            .unwrap_or("<untitled>");
        let new_title = schema
            .get("title")
            .and_then(Value::as_str)
            .unwrap_or("<untitled>");
        return Err(anyhow!(
            "schema definition collision in {location}: {name} (existing title: {existing_title}, new title: {new_title}); use #[schemars(rename = \"...\")] to rename one of the conflicting schema definitions"
        ));
    }

    definitions.insert(name, schema);
    Ok(())
}

fn write_json_schema_with_return<T>(out_dir: &Path, name: &str) -> Result<GeneratedSchema>
where
    T: JsonSchema,
{
    let file_stem = name.trim();
    let (raw_namespace, logical_name) = split_namespace(file_stem);
    let include_in_json_codegen =
        raw_namespace != Some("v1") || JSON_V1_ALLOWLIST.contains(&logical_name);
    let schema = schema_for!(T);
    let mut schema_value = serde_json::to_value(schema)?;

View on GitHub (pinned to 339751715c)