openai/codex · error · anyhow::Error

network.mitm_hooks requires network.mitm = true

Error message

network.mitm_hooks requires network.mitm = true

What it means

Configuration validation error raised in validate_mitm_hook_config: MITM hooks are declared in NetworkProxyConfig but the MITM interception mode itself (network.mitm) is disabled. Hooks are only evaluated on traffic that flows through the MITM inspector, so with mitm=false they could never fire; the config is rejected up front rather than silently ignoring hooks.

Solutions

  1. Set network.mitm = true in the network proxy configuration so hooks can be evaluated
  2. Remove the network.mitm_hooks entries if interception is not wanted
Defensive patterns

Strategy: validation

When it happens

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

Appendix: source

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

}

pub type MitmHooksByHost = BTreeMap<String, Vec<MitmHook>>;

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum HookEvaluation {
    NoHooksForHost,
    Matched { actions: MitmHookActions },
    HookedHostNoMatch,
}

pub(crate) fn validate_mitm_hook_config(config: &NetworkProxyConfig) -> Result<()> {
    let hooks = &config.mitm_hooks;
    if hooks.is_empty() {
        return Ok(());
    }

    if !config.mitm {
        return Err(anyhow!("network.mitm_hooks requires network.mitm = true"));
    }

    for (hook_index, hook) in hooks.iter().enumerate() {
        let host = normalize_hook_host(&hook.host)
            .with_context(|| format!("invalid network.mitm_hooks[{hook_index}].host"))?;

        let methods = normalize_methods(&hook.matcher.methods)
            .with_context(|| format!("invalid network.mitm_hooks[{hook_index}].match.methods"))?;
        if methods.is_empty() {
            return Err(anyhow!(
                "network.mitm_hooks[{hook_index}].match.methods must not be empty"
            ));
        }

        let path_prefixes =
            compile_path_matchers(&hook.matcher.path_prefixes).with_context(|| {
                format!("invalid network.mitm_hooks[{hook_index}].match.path_prefixes")
            })?;

View on GitHub (pinned to 339751715c)