openai/codex · error · anyhow::Error
methods must not contain empty entries
Error message
methods must not contain empty entries
What it means
normalize_methods trims and uppercases each entry of match.methods; an entry that becomes empty afterwards — "" or whitespace-only — is rejected with 'methods must not contain empty entries'. The list itself must also be non-empty, which is a separate check ('match.methods must not be empty').
Source
Thrown at codex-rs/network-proxy/src/mitm_hook.rs:555
let normalized = normalize_host(host);
if normalized.is_empty() {
return Err(anyhow!("host must not be empty"));
}
if normalized.contains('*') {
return Err(anyhow!(
"MITM hook hosts must be exact hosts and cannot contain wildcards"
));
}
Ok(normalized)
}
fn normalize_methods(methods: &[String]) -> Result<Vec<String>> {
methods
.iter()
.map(|method| {
let normalized = method.trim().to_ascii_uppercase();
if normalized.is_empty() {
return Err(anyhow!("methods must not contain empty entries"));
}
Ok(normalized)
})
.collect()
}
fn validate_query_constraints(query: &BTreeMap<String, Vec<String>>) -> Result<()> {
for (name, values) in query {
let normalized = normalize_query_name(name)?;
if normalized.is_empty() {
return Err(anyhow!("query keys must not be empty"));
}
if values.is_empty() {
return Err(anyhow!(
"query key {name:?} must list at least one allowed value"
));
}
let _ = compile_value_matchers(values)View on GitHub (pinned to 339751715c)
Solutions
- Remove blank entries from methods
- Write standard HTTP method names ("GET", "POST", ...); case is normalized automatically
- If the list ends up empty, that is the separate 'must not be empty' error — keep at least one method
Example fix
# before methods = ["GET", ""] # after methods = ["GET", "POST"]
Defensive patterns
Strategy: validation
Validate before calling
// Rust — no blank method entries
for (i, hook) in config.mitm_hooks.iter().enumerate() {
if hook.matcher.methods.iter().any(|m| m.trim().is_empty()) {
return Err(anyhow!("network.mitm_hooks[{i}].match.methods has an empty entry"));
}
} Type guard
fn methods_have_no_blanks(hook: &MitmHookConfig) -> bool {
hook.matcher.methods.iter().all(|m| !m.trim().is_empty())
} Try / catch
match validate_mitm_hook_config(&config) {
Ok(()) => {}
Err(err) => eprintln!("{err:#}"), // 'invalid network.mitm_hooks[i].match.methods: methods must not contain empty entries'
} Prevention
- Write methods explicitly and drop blank strings from generated lists
- Case does not matter ('get' is fine); emptiness does
- Keep at least one method per hook — an empty list trips the separate must-not-be-empty check
When it happens
Trigger: methods = [""], or methods = ["GET", " "] in a [[network.mitm_hooks]] entry; methods matching is case-insensitive ('get' normalizes to 'GET'), but blank entries fail.
Common situations: Lists built by string concatenation that emit an empty element; trailing commas parsed as empty entries; editing out one method but leaving its separator.
Understand the failure class
Background: Config validation failed: what "invalid value for {key}" and settings-rejection errors mean across 19 open-source libraries — this error's family across 19 libraries.
Related errors
- network.mitm_hooks[{hook_index}].match.body is reserved for
- network.mitm_hooks[{hook_index}].host must not be empty
- expected exactly one of secret_env_var or secret_file
- path_prefixes must not contain empty entries
- glob pattern must not be empty
AI-assisted analysis of openai/codex@339751715c (2026-08-25).
Data as JSON: /api/errors/9a13f6d66bf0092b.
Report an issue: GitHub.