openai/codex · error · anyhow::Error

path_prefixes must not contain empty entries

Error message

path_prefixes must not contain empty entries

What it means

compile_path_matchers turns each path_prefixes entry into either a Prefix literal or a compiled glob. A literal entry that is empty after parsing — the empty string, or 'literal:' with nothing after the colon — is meaningless as a prefix and is rejected with 'path_prefixes must not contain empty entries'. An empty list is a different error ('must not be empty').

Source

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

}

impl ValueMatcher {
    fn matches(&self, candidate: &str) -> bool {
        match self {
            Self::Exact(value) => value == candidate,
            Self::Glob(glob) => glob.is_match(candidate),
        }
    }
}

fn compile_path_matchers(path_prefixes: &[String]) -> Result<Vec<PathMatcher>> {
    path_prefixes
        .iter()
        .map(|prefix| {
            match parse_matcher_pattern(prefix)? {
                MatcherPattern::Literal(prefix) => {
                    if prefix.is_empty() {
                        return Err(anyhow!("path_prefixes must not contain empty entries"));
                    }
                    Ok(PathMatcher::Prefix(prefix.to_string()))
                }
                MatcherPattern::Glob(glob_pattern) => Ok(PathMatcher::Glob(compile_glob_matcher(
                    glob_pattern,
                    /*literal_separator*/ true,
                )?)),
            }
        })
        .collect()
}

fn compile_value_matchers(values: &[String]) -> Result<Vec<ValueMatcher>> {
    values
        .iter()
        .map(|value| match parse_matcher_pattern(value)? {
            MatcherPattern::Literal(value) => Ok(ValueMatcher::Exact(value.to_string())),
            MatcherPattern::Glob(glob_pattern) => Ok(ValueMatcher::Glob(compile_glob_matcher(

View on GitHub (pinned to 339751715c)

Solutions

  1. Delete empty strings from path_prefixes
  2. To match every path use "/" — every request path starts with a slash
  3. Use pattern: globs such as "pattern:/api/*/items" when plain prefix matching is too coarse

Example fix

# before
path_prefixes = ["/v1/", ""]

# after
path_prefixes = ["/v1/"]
Defensive patterns

Strategy: validation

Validate before calling

// Rust — no empty literal prefix entries
for hook in &config.mitm_hooks {
    if hook.matcher.path_prefixes.iter()
        .any(|p| p.is_empty() || p == "literal:")
    {
        return Err(anyhow!("path_prefixes contains an empty entry"));
    }
}

Type guard

fn path_prefixes_are_nonempty(hook: &MitmHookConfig) -> bool {
    hook.matcher.path_prefixes.iter().all(|p| !p.is_empty() && p != "literal:")
}

Try / catch

match validate_mitm_hook_config(&config) {
    Ok(()) => {}
    Err(err) => eprintln!("{err:#}"), // context names the hook and path_prefixes field
}

Prevention

When it happens

Trigger: path_prefixes = [""], path_prefixes = ["/v1/", ""], or path_prefixes = ["literal:"] inside any [[network.mitm_hooks]] entry; note that 'pattern:' with an empty body raises the separate 'glob pattern must not be empty' error.

Common situations: Template loops or concatenation emitting an empty iteration; copying a path list with a blank line; intending 'match everything' and leaving a blank entry instead of "/".

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


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/2965363403264d0f. Report an issue: GitHub.