Skip to content

fix(files): prune dependency dirs in expandFileGlobs before fast-glob traversal#410

Draft
dcramer wants to merge 4 commits into
mainfrom
fix/prune-vendor-dirs-in-glob-expansion
Draft

fix(files): prune dependency dirs in expandFileGlobs before fast-glob traversal#410
dcramer wants to merge 4 commits into
mainfrom
fix/prune-vendor-dirs-in-glob-expansion

fix(files): add MAX_GLOB_FILE_RESULTS guardrail and WardenGlobExpansi…

8c4d39e
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: code-review completed Jun 16, 2026 in 0s

1 issue

code-review: Found 1 issue (1 medium)

Medium

`MAX_GLOB_FILE_RESULTS` guard counts pre-gitignore results, throwing false errors on repos with large gitignored dirs outside the prune list - `packages/warden/src/cli/files.ts:284-287`

The files.length >= MAX_GLOB_FILE_RESULTS check runs right after fg(), before gitignore rules are applied. A repo with a gitignored directory that is not in BUILTIN_PRUNE_DIRECTORY_PATTERNS (e.g. Python .venv/, target/, __pycache__/) containing 10,000+ matching files trips the guard and throws WardenGlobExpansionError, causing warden to exit 1 even though gitignore filtering would have reduced the result to the real source files. Move the guard after the gitignore filtering step (or after the !useGitignore/no-git-root returns) so it bounds the final result set.


⏱ 6m 37s · 898.2k in / 61.0k out · $2.09

Annotations

Check warning on line 287 in packages/warden/src/cli/files.ts

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

`MAX_GLOB_FILE_RESULTS` guard counts pre-gitignore results, throwing false errors on repos with large gitignored dirs outside the prune list

The `files.length >= MAX_GLOB_FILE_RESULTS` check runs right after `fg()`, before gitignore rules are applied. A repo with a gitignored directory that is not in `BUILTIN_PRUNE_DIRECTORY_PATTERNS` (e.g. Python `.venv/`, `target/`, `__pycache__/`) containing 10,000+ matching files trips the guard and throws `WardenGlobExpansionError`, causing warden to exit 1 even though gitignore filtering would have reduced the result to the real source files. Move the guard after the gitignore filtering step (or after the `!useGitignore`/no-git-root returns) so it bounds the final result set.