Skip to content

diag(extraction): log when the git-based scan falls back to a filesystem walk - #1568

Draft
milos85vasic wants to merge 1 commit into
colbymchenry:mainfrom
milos85vasic:fix/nested-gitignore-fallback-diagnostics
Draft

diag(extraction): log when the git-based scan falls back to a filesystem walk#1568
milos85vasic wants to merge 1 commit into
colbymchenry:mainfrom
milos85vasic:fix/nested-gitignore-fallback-diagnostics

Conversation

@milos85vasic

Copy link
Copy Markdown

What

Adds one logDebug() call in getGitVisibleFiles()'s outer catch block, naming the exception before falling back to the independent scanDirectoryWalk() filesystem-walk path. Zero behavior change — purely diagnostic, gated by the project's existing CODEGRAPH_DEBUG convention (same as every other logDebug() call in this file).

Why

getGitVisibleFiles() currently silently returns null on any exception (git missing, a rev-parse/ls-files timeout or buffer overrun under load, an unreadable repo, etc.), sending every caller to scanDirectoryWalk() with no signal that the fast, fully git-delegated path was skipped.

That makes a report like #1567 (a real ~63x file-count blowup where git check-ignore -v proves git itself correctly excludes a nested-.gitignore'd node_modules tree, yet codegraph init walked into it anyway) hard to triage after the fact: both getGitVisibleFiles() and scanDirectoryWalk() independently implement nested-.gitignore handling and both look correct to me on inspection, but there is currently no way to tell which one actually ran for a given index/init/sync on the reporting host. This PR closes that specific observability gap.

What this is NOT

This is not a fix for #1567's regression itself. I traced both scanning implementations and could not identify a concrete defect in either through static reading, and I could not reproduce the reported blowup in two synthetic fixtures (up to 63 nested .gitignore files / 960 excluded files / .bin symlinks) run against the actual v1.5.0 binary — see the issue for full detail on both the confirmed root-cause evidence and the inconclusive reproduction attempts. I'm offering this small, safe, unambiguously-correct diagnostic improvement now rather than guessing at a behavioral fix I can't prove addresses the real trigger.

Testing

  • npx tsc --noEmit -p . — clean, no new errors.
  • No behavior change on any success path; only the previously-silent catch branch gains a log call using the existing logDebug(message, context) signature already used elsewhere in this same file (e.g. 'Skipping unresolvable directory').

Related

…tem walk

getGitVisibleFiles() silently returned null on ANY exception (git missing,
a rev-parse/ls-files timeout or buffer overrun under load, an unreadable
repo, etc.), sending every caller to the independent scanDirectoryWalk()
filesystem-walk fallback with zero signal that the fast, fully
git-delegated path was skipped.

That makes a report like "codegraph walked into a directory a nested (non-
root) .gitignore excludes for git" nearly untriageable after the fact: both
scanning implementations exist to respect .gitignore correctly on their own
reading, but there is currently no way to tell which of the two actually
ran for a given index/init/sync — so a maintainer investigating such a
report has to re-instrument the source themselves to even confirm the
fallback fired.

This adds one logDebug() call (the project's existing CODEGRAPH_DEBUG-gated
convention, already used elsewhere in this same file) naming the exception
before falling back, with zero behavior change otherwise.

Context: reported against v1.5.0 in a real ~63x file-count blowup (509 ->
32,260 files) on a project with git-confirmed-correct nested .gitignore
exclusions (git check-ignore -v: frontend/.gitignore:10 and
extension/.gitignore:2 both correctly exclude their node_modules trees).
Neither scanning path in the current source could be shown to mis-handle a
synthetic nested-.gitignore fixture in isolation (tested up to 63 nested
.gitignore files / 960 excluded files / .bin symlinks against the actual
v1.5.0 binary), so this defensive-hardening diagnostic is offered instead
of a speculative behavioral fix for the reported regression itself. See
the linked issue for full reproduction evidence.
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.

1 participant