openai/codex · error

invalid shell environment policy in

Error message

invalid shell environment policy in {}: {error}

What it means

validate_enabled_config_layers checks each enabled layer's shell environment policy setting; a layer in {file} declared a policy that failed to parse/validate ({error} is the underlying reason), and mixed or malformed policy forms must be caught before merging layers.

Solutions

  1. Fix the shell environment policy entries in the indicated file per the reported error.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at codex-rs/config/src/state.rs:514 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/8e4ffcf35f3b6321. Report an issue: GitHub.

Appendix: source

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

    /// Requirement sources are tracked separately and are not included here.
    pub fn all_layers_low_to_high(&self) -> impl DoubleEndedIterator<Item = &ConfigLayerEntry> {
        self.layers.iter()
    }

    /// Returns all config layers, including disabled layers, from highest
    /// precedence to lowest.
    ///
    /// Requirement sources are tracked separately and are not included here.
    pub fn all_layers_high_to_low(&self) -> impl DoubleEndedIterator<Item = &ConfigLayerEntry> {
        self.all_layers_low_to_high().rev()
    }
}

/// Validates before merging so mixed forms and malformed filter entries cannot be normalized away.
pub(crate) fn validate_enabled_config_layers(layers: &[ConfigLayerEntry]) -> std::io::Result<()> {
    for layer in layers.iter().filter(|layer| !layer.is_disabled()) {
        validate_shell_environment_policy_filter_config(&layer.config).map_err(|error| {
            std::io::Error::new(
                std::io::ErrorKind::InvalidData,
                format!(
                    "invalid shell environment policy in {}: {error}",
                    format_config_layer_source(&layer.name, CONFIG_TOML_FILE)
                ),
            )
        })?;
    }
    Ok(())
}

/// Ensures precedence ordering of config layers is correct.
fn verify_layer_ordering(layers: &[ConfigLayerEntry]) -> std::io::Result<()> {
    if !layers.iter().map(|layer| &layer.name).is_sorted() {
        return Err(std::io::Error::new(
            std::io::ErrorKind::InvalidData,
            "config layers are not in correct precedence order",
        ));

View on GitHub (pinned to 339751715c)