vectordotdev/vector · error

failed to read glob pattern

Error message

failed to read glob pattern

What it means

Vector's file source expands every `include` glob with `glob::glob_with` and treats a malformed pattern as unrecoverable, panicking with 'failed to read glob pattern'. The glob crate returns a PatternError when the pattern violates its syntax, such as an unbalanced `[` or `{`, an inverted character range like `[z-a]`, or a trailing backslash. The panic fires when the Glob paths provider first resolves paths, i.e. when the file source starts or reloads, and it tears down the whole topology.

Source

Thrown at lib/file-source/src/paths_provider.rs:82

        Some(Self {
            include_patterns,
            exclude_patterns,
            glob_match_options,
            emitter,
        })
    }
}

impl<E: FileSourceInternalEvents> PathsProvider for Glob<E> {
    type IntoIter = Vec<PathBuf>;

    fn paths(&self) -> Self::IntoIter {
        self.include_patterns
            .iter()
            .flat_map(|include_pattern| {
                glob::glob_with(include_pattern.as_str(), self.glob_match_options)
                    .expect("failed to read glob pattern")
                    .filter_map(|val| {
                        val.map_err(|error| {
                            self.emitter
                                .emit_path_globbing_failed(error.path(), error.error())
                        })
                        .ok()
                    })
            })
            .filter(|candidate_path: &PathBuf| -> bool {
                !self.exclude_patterns.iter().any(|exclude_pattern| {
                    let candidate_path_str = candidate_path.to_str().unwrap();
                    exclude_pattern.matches(candidate_path_str)
                })
            })
            .collect()
    }
}

View on GitHub (pinned to 3708c39b12)

Solutions

  1. Fix the pattern syntax: close every [ ... ] and { ... }, use ascending ranges like [a-z], and escape literal brackets as \[
  2. If the literal filename contains [ or {, replace it with a * or ? wildcard instead of escaping
  3. Add a pre-deploy check that runs glob::Pattern::new (or glob::glob_with with the same match options) over every include/exclude pattern, since `vector validate` only checks config shape and may not compile the glob

Example fix

# before (panics at startup)
[sources.in]
type = "file"
include = ["/var/log/app/[0-9"]

# after
[sources.in]
type = "file"
include = ["/var/log/app/[0-9]*"]
Defensive patterns

Strategy: validation

Validate before calling

fn validate_globs(patterns: &[String]) -> Result<(), String> {
    for p in patterns {
        if glob::Pattern::new(p).is_err() {
            return Err(format!("invalid glob pattern: {p}"));
        }
    }
    Ok(())
}

// run before applying/starting the file source config
validate_globs(&config.include)?;

Type guard

fn is_valid_glob(pattern: &str) -> bool {
    glob::Pattern::new(pattern).is_ok()
}

Prevention

When it happens

Trigger: Setting `include` (or a component feeding Glob::new) to a syntactically invalid glob such as "/var/log/app/[0-9", "[z-a].log", or "{a,b" and then starting Vector or reloading config; paths_provider.rs calls glob_with(...).expect(...) for every include pattern on each paths() call.

Common situations: Typo'd log path patterns in file source config; copying bash extglob or regex syntax (e.g. unescaped brackets) into a glob field; config templating (Helm/Jinja) that emits an unterminated bracket for empty values; paths that literally contain `[` which must be escaped as `\[` in glob syntax.

Related errors


AI-assisted analysis of vectordotdev/vector@3708c39b12 (2026-08-20). Data as JSON: /api/errors/b46b6a9a2ec17587. Report an issue: GitHub.