Skip to content

fix: reject invalid regexes in --ignore-all-in-file - #658

Merged
bootandy merged 1 commit into
bootandy:masterfrom
pcbeingused333:fix/ignore-file-invalid-regex
Nov 25, 2026
Merged

bootandy merged 1 commit into
bootandy:masterfrom
pcbeingused333:fix/ignore-file-invalid-regex

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

-I / --ignore-all-in-file silently drops any line that is not a valid regex, so paths the user meant to exclude still show up and dust exits 0.

For example, with an ignore file containing [secret and ^other$, the first line is discarded without any message.

Cause: the lines are compiled with Regex::new and the errors are thrown away with filter_map(|x| x.ok()).

Fix: compile the lines with get_regex_value, the helper already used for --filter and --invert-filter. The -I help says its entries are added to the --invert-filter regexes, so a bad entry now prints the same Ignoring bad value for regex ... error and exits with code 1.

Note the behaviour change: an ignore file with a line such as *.log (a glob, not a regex) used to run with that line skipped, and now fails. If you would rather warn and continue, I can change it to that.

This is separate from #657, which handles an unreadable file; the two touch neighbouring lines.

Test: added test_ignore_all_in_file_rejects_invalid_regex, which fails before the change (exit code 0) and passes after. cargo test and cargo fmt --check pass.


AI assistance (Claude Code) was used to prepare this change.

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@bootandy
bootandy merged commit 8239ea6 into bootandy:master Nov 25, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants