openai/codex · error · std::io::Error

project layers are not ordered from root to cwd

Error message

project layers are not ordered from root to cwd

What it means

verify_layer_ordering walks the layer stack and requires project layers to appear ordered from the repository root down to the cwd (each subsequent .codex folder nested deeper). Encountering an out-of-order pair means the discovery walk produced an inconsistent stack — an internal invariant failure.

Solutions

  1. Order the project config layers from filesystem root down to the current working directory.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at codex-rs/config/src/state.rs:558 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/6fffbf214c0f9e47. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/config/src/state.rs:558

    for layer in layers {
        if let ConfigLayerSource::Project {
            dot_codex_folder: current_project_dot_codex_folder,
        } = &layer.name
        {
            if let Some(previous) = previous_project_dot_codex_folder {
                let Some(parent) = previous.as_path().parent() else {
                    return Err(std::io::Error::new(
                        std::io::ErrorKind::InvalidData,
                        "project layer has no parent directory",
                    ));
                };
                if previous == current_project_dot_codex_folder
                    || !current_project_dot_codex_folder
                        .as_path()
                        .ancestors()
                        .any(|ancestor| ancestor == parent)
                {
                    return Err(std::io::Error::new(
                        std::io::ErrorKind::InvalidData,
                        "project layers are not ordered from root to cwd",
                    ));
                }
            }
            previous_project_dot_codex_folder = Some(current_project_dot_codex_folder);
        }
    }

    Ok(())
}

#[cfg(test)]
#[path = "state_tests.rs"]
mod tests;

View on GitHub (pinned to 339751715c)