{"record":{"id":"7967a7bdf70f5d3e","repo":"XAMPPRocky/tokei","slug":"excludes-provided-were-invalid","errorCode":null,"errorMessage":"Excludes provided were invalid","messagePattern":"Excludes provided were invalid","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/utils/fs.rs","lineNumber":37,"sourceCode":") {\n    let languages = parking_lot::Mutex::new(languages);\n    let (tx, rx) = crossbeam_channel::unbounded();\n\n    let mut paths = paths.iter();\n    let mut walker = WalkBuilder::new(paths.next().unwrap());\n\n    for path in paths {\n        walker.add(path);\n    }\n\n    if !ignored_directories.is_empty() {\n        let mut overrides = OverrideBuilder::new(\".\");\n\n        for ignored in ignored_directories {\n            rs_error!(overrides.add(&format!(\"!{}\", ignored)));\n        }\n\n        walker.overrides(overrides.build().expect(\"Excludes provided were invalid\"));\n    }\n\n    let ignore = config.no_ignore.map(|b| !b).unwrap_or(true);\n    let ignore_dot = ignore && config.no_ignore_dot.map(|b| !b).unwrap_or(true);\n    let ignore_vcs = ignore && config.no_ignore_vcs.map(|b| !b).unwrap_or(true);\n\n    // Custom ignore files always work even if the `ignore` option is false,\n    // so we only add if that option is not present.\n    if ignore_dot {\n        walker.add_custom_ignore_filename(IGNORE_FILE);\n    }\n\n    walker\n        .git_exclude(ignore_vcs)\n        .git_global(ignore_vcs)\n        .git_ignore(ignore_vcs)\n        .hidden(config.hidden.map(|b| !b).unwrap_or(true))\n        .ignore(ignore_dot)","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/XAMPPRocky/tokei/blob/fa44e5194060305576514d59b850353643afbfc8/src/utils/fs.rs#L19-L55","documentation":"This panic comes from `overrides.build().expect(\"Excludes provided were invalid\")` in `get_all_files` (src/utils/fs.rs:37). It wraps the `OverrideBuilder::build()` call from the `ignore` crate, which returns `Err` if any glob added via `overrides.add(\"!<dir>\")` is not a syntactically valid glob. The tool cannot construct the directory walker's override set, so it aborts instead of walking with incorrect exclusion rules.","triggerScenarios":"Calling `get_all_files` with an `ignored_directories` entry that produces an invalid glob when prefixed with `!` — e.g. a path containing an unclosed `[`, an invalid `**` placement, or other glob metacharacter mistakes. Note that entries with simple malformed glob syntax can panic here even though each individual `overrides.add` was checked by `rs_error!` earlier (build-time validation can still fail).","commonSituations":"Users writing exclude patterns copied from .gitignore syntax with unsupported glob features; a config value like `ignored_directories = [\"node_modules[\", \"target/**/\"]` with bracket/escape errors; shell-quoting stripping or adding characters so the pattern reaching the builder differs from what the user intended; trailing slashes or absolute paths used where a relative glob is expected.","solutions":["Fix the ignore entry in the config/CLI argument so it is a valid glob — remove or escape stray metacharacters (`[`, `]`, `{`, `}`), e.g. use `node_modules` or `**/node_modules/**`","Test the pattern with a glob matcher (e.g. the `globset` crate or a gitignore checker) before passing it to the tool","Simplify the pattern: plain directory names like `target` or `dist` are usually enough; avoid absolute paths and trailing slashes","If you maintain the library, replace `.expect` with error propagation so the user's config reports which pattern was invalid instead of panicking"],"exampleFix":"// before\nignored_directories = [\"node_modules[\", \"target/\"]\n// after\nignored_directories = [\"node_modules\", \"target\"]","handlingStrategy":"validation","validationCode":"fn is_valid_exclude_pattern(pattern: &str) -> bool {\n    // reject unbalanced brackets/braces and absolute paths before adding \"!\"\n    let open = pattern.matches('[').count();\n    let close = pattern.matches(']').count();\n    let brace_open = pattern.matches('{').count();\n    let brace_close = pattern.matches('}').count();\n    open == close && brace_open == brace_close\n        && !pattern.starts_with('/')\n        && !globset::Glob::new(pattern).is_err()\n}","typeGuard":null,"tryCatchPattern":"let overrides = match overrides_builder.build() {\n    Ok(o) => o,\n    Err(e) => {\n        eprintln!(\"Invalid exclude pattern in config: {}\", e);\n        return Err(e);\n    }\n};\nwalker.overrides(overrides);","preventionTips":["Keep ignore entries as simple relative directory names (`target`, `node_modules`, `dist`) unless globs are truly needed","Validate glob syntax with the `globset` crate before writing patterns to config","Do not use absolute paths or leading/trailing slashes in exclude entries","Check shell quoting when patterns come from the command line — test the exact string the tool receives","Document the accepted glob syntax for users editing the config file"],"tags":["rust","glob","ignore","panic","configuration"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"fa44e5194060305576514d59b850353643afbfc8","analyzedAt":"2026-09-06T07:54:23.092Z","contentChangedAt":"2026-09-06T07:54:23.092Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}