fix(scanner): traverse symlinked dirs in resolveEncodedProjectPath + add tests - #21
Closed
nandanadileep wants to merge 1 commit into
Closed
Conversation
…loses #17) Two changes to resolveEncodedProjectPath: 1. Include symlinks when listing directory candidates. readdir withFileTypes returns Dirent objects whose isDirectory() returns false for symlinks even when they point to directories. On macOS /tmp is a symlink to /private/tmp, so the DFS could never match any path under /tmp. Fix: filter with isDirectory() || isSymbolicLink() so the resolver descends through symlinked dirs. The subsequent readdir/exists calls already follow symlinks transparently. 2. Export the function so it can be unit-tested directly. Adds tests/unit/test-resolve-encoded-path.mjs with 8 tests covering: - Baseline paths (no special characters) - Underscore in directory name (encoded same as hyphen — issue #17 case 1) - Hyphen in directory name (ambiguous segment boundary — issue #17 case 2) - Mixed underscore + hyphen path requiring DFS backtracking - Non-existent encoded path → null
Member
|
Thanks for the symlink traversal fix. I ported the bug fix onto the current Claude harness adapter rather than merging this branch directly, since this PR conflicted with the scanner refactor. Merged replacement: #29 What carried over:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the remaining gap in #17 by addressing a secondary bug discovered while writing tests, and adds a dedicated test suite to prevent regressions.
Root causes fixed
Bug 1 — already merged (
9588e8a): Greedy resolver couldn't match directory names containing underscores (e.g.My_Projects→ encoded asMy-Projects). Fixed with DFS + normalization.Bug 2 — this PR:
readdirwithwithFileTypes: truereturnsDirentobjects.Dirent.isDirectory()returnsfalsefor symlinks even when they point to directories. On macOS/tmpis a symlink to/private/tmp, so the DFS dead-ended at/without ever matchingtmp. Any project path under a symlinked directory silently resolved tonull.Fix: Change the filter from
e.isDirectory()toe.isDirectory() || e.isSymbolicLink(). The subsequentreaddir/existscalls already follow symlinks transparently, so no other changes are needed.Also exports
resolveEncodedProjectPathto enable direct unit testing.Tests added (
tests/unit/test-resolve-encoded-path.mjs)8 tests covering the exact scenarios from the issue report:
nullMy_Projects)Parent_Dir)my-org)core_repos/my-tool)nullAll 113 unit tests pass.
Test plan
node --test tests/unit/test-resolve-encoded-path.mjs— 8/8 passnode --test tests/unit/*.mjs— 113/113 pass/tmp → /private/tmpreproduces bug 2Closes #17