openai/codex · error · anyhow::Error

schema missing definitions

Error message

{label} schema missing definitions: {}

What it means

The schema contains $ref pointers whose target names are not present in the `definitions` map — collect_missing_definitions found dangling references, so the exported schema bundle is incomplete and would break TS/JSON consumers.

Solutions

  1. Verify all referenced types are included when the schema is assembled
  2. File an internal bug against the schema export pipeline if refs point at types that were filtered out
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at codex-rs/app-server-protocol/src/export.rs:1247 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/ea4f97c6fcb4ed5a. Report an issue: GitHub.

Appendix: source

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

            .iter()
            .find_map(|child| first_ref_with_prefix(child, prefix)),
        _ => None,
    }
}

fn ensure_referenced_definitions_present(schema: &Value, label: &str) -> Result<()> {
    let definitions = schema
        .get("definitions")
        .and_then(Value::as_object)
        .ok_or_else(|| anyhow!("expected definitions map in {label} schema"))?;
    let mut missing = HashSet::new();
    collect_missing_definitions(schema, definitions, &mut missing);
    if missing.is_empty() {
        return Ok(());
    }
    let mut missing_names: Vec<String> = missing.into_iter().collect();
    missing_names.sort();
    Err(anyhow!(
        "{label} schema missing definitions: {}",
        missing_names.join(", ")
    ))
}

fn collect_missing_definitions(
    value: &Value,
    definitions: &Map<String, Value>,
    missing: &mut HashSet<String>,
) {
    match value {
        Value::Object(obj) => {
            if let Some(Value::String(reference)) = obj.get("$ref")
                && let Some(name) = reference.strip_prefix("#/definitions/")
            {
                let name = name.split('/').next().unwrap_or(name);
                if !definitions.contains_key(name) {
                    missing.insert(name.to_string());

View on GitHub (pinned to 339751715c)