{"record":{"id":"d2da56650bacbd1d","repo":"openai/codex","slug":"host-must-not-be-empty","errorCode":null,"errorMessage":"host must not be empty","messagePattern":"host must not be empty","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/network-proxy/src/mitm_hook.rs","lineNumber":539,"sourceCode":"\nfn compile_glob_matcher(pattern: &str, literal_separator: bool) -> Result<CompiledGlobMatcher> {\n    let mut builder = GlobBuilder::new(pattern);\n    builder\n        .backslash_escape(true)\n        .literal_separator(literal_separator);\n    builder\n        .build()\n        .map(|glob| CompiledGlobMatcher {\n            pattern: pattern.to_string(),\n            matcher: glob.compile_matcher(),\n        })\n        .map_err(|err| anyhow!(\"invalid glob pattern {pattern:?}: {err}\"))\n}\n\nfn normalize_hook_host(host: &str) -> Result<String> {\n    let normalized = normalize_host(host);\n    if normalized.is_empty() {\n        return Err(anyhow!(\"host must not be empty\"));\n    }\n    if normalized.contains('*') {\n        return Err(anyhow!(\n            \"MITM hook hosts must be exact hosts and cannot contain wildcards\"\n        ));\n    }\n    Ok(normalized)\n}\n\nfn normalize_methods(methods: &[String]) -> Result<Vec<String>> {\n    methods\n        .iter()\n        .map(|method| {\n            let normalized = method.trim().to_ascii_uppercase();\n            if normalized.is_empty() {\n                return Err(anyhow!(\"methods must not contain empty entries\"));\n            }\n            Ok(normalized)","sourceCodeStart":521,"sourceCodeEnd":557,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/network-proxy/src/mitm_hook.rs#L521-L557","documentation":"normalize_hook_host runs each hook's host through normalize_host (the trim/lowercase normalization used for hook lookup) and rejects hosts that normalize to nothing with 'host must not be empty'. Inside validate_mitm_hook_config the failure is wrapped as 'invalid network.mitm_hooks[i].host: host must not be empty', so the offending hook's index is visible in the anyhow context chain.","triggerScenarios":"host key omitted (serde default is \"\"), host = \"\", or host = \"   \" in a [[network.mitm_hooks]] entry; raised from both validate_mitm_hook_config and compile_mitm_hooks_with_resolvers.","commonSituations":"Writing only match/actions and forgetting host; placeholder not substituted by templating; whitespace introduced by generated config.","solutions":["Set host to an exact, bare hostname such as host = \"api.example.com\" — no scheme, path, or trailing slash","Use the hook index in the 'invalid network.mitm_hooks[i].host' context to locate the offending entry","Lint generated config for empty hosts before deploying"],"exampleFix":"# before — host omitted / empty\n[[network.mitm_hooks]]\nhost = \"\"\n\n# after\n[[network.mitm_hooks]]\nhost = \"api.example.com\"","handlingStrategy":"validation","validationCode":"// Rust — host must survive normalization non-empty\nfor (i, hook) in config.mitm_hooks.iter().enumerate() {\n    if hook.host.trim().is_empty() {\n        return Err(anyhow!(\"network.mitm_hooks[{i}].host is empty\"));\n    }\n}","typeGuard":"fn hook_host_nonempty(hook: &MitmHookConfig) -> bool {\n    !hook.host.trim().is_empty()\n}","tryCatchPattern":"match validate_mitm_hook_config(&config) {\n    Ok(()) => {}\n    Err(err) => eprintln!(\"{err:#}\"), // 'invalid network.mitm_hooks[i].host: host must not be empty'\n}","preventionTips":["Write bare hostnames (api.example.com) with no scheme or path","Treat a missing host as a template error, not a default","Check the hook index in the context message to jump straight to the entry"],"tags":["network","mitm","codex","config-validation","required-field","hostname"],"backgroundTag":"empty-required-config-field","analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}