openai/codex · error · anyhow::Error

secret_file must not be empty

Error message

secret_file must not be empty

What it means

Guard in parse_secret_file: the configured secret_file value is empty or whitespace-only, so no file path can be resolved. parse_secret_file is a validation helper used by validate_injected_headers and compile_injected_header; the at-fault input is the empty string in the hook header's secret_file field.

Solutions

  1. Provide a real file path in secret_file
  2. Use secret_env_var instead if the secret comes from the environment
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at codex-rs/network-proxy/src/mitm_hook.rs:634 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/17488a7812591731. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/network-proxy/src/mitm_hook.rs:634

            }
            _ => {
                return Err(anyhow!(
                    "expected exactly one of secret_env_var or secret_file"
                ));
            }
        }
    }
    Ok(())
}

fn parse_header_name(name: &str) -> Result<HeaderName> {
    HeaderName::from_bytes(name.as_bytes())
        .map_err(|err| anyhow!("invalid header name {name:?}: {err}"))
}

fn parse_secret_file(path: &str) -> Result<AbsolutePathBuf> {
    if path.trim().is_empty() {
        return Err(anyhow!("secret_file must not be empty"));
    }
    let path = Path::new(path);
    if !path.is_absolute() {
        return Err(anyhow!("secret_file must be an absolute path: {path:?}"));
    }
    AbsolutePathBuf::from_absolute_path(path)
        .with_context(|| format!("secret_file must be an absolute path: {path:?}"))
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::NetworkMode;
    use crate::config::NetworkProxyConfig;
    use pretty_assertions::assert_eq;
    use rama_http::Body;
    use rama_http::Method;
    use tempfile::NamedTempFile;

View on GitHub (pinned to 339751715c)