Repository navigation
fix(util): skip access-denied paths during FSUtil.up traversal - #67564
SomSamantray wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
The fix looks correct and minimal: denied parent folders are now treated as missing in FSUtil.up, the same way resolve and readFileStringSafe already treat them. Other errors such as EIO still fail. I couldn't reproduce the Windows ACL setup here, since Linux won't produce that failure honestly. The new tests fail on the base and pass with this change, and tsc type-checks pass for packages/util and packages/core. Git and project discovery also call up. They used to give up on any error; now they skip a denied parent and keep searching upward, which seems like the better behaviour.
Public API: unchanged.
One small point: the new ConfigDiscovery.discover test adds about 65 lines of custom setup to check what the FSUtil.up unit tests already cover. It can be dropped to keep the change minimal.
There was a problem hiding this comment.
The redundant ConfigDiscovery.discover test is gone, which addresses my earlier comment. What's left is the one-line fix plus the small FSUtil.up tests, which pass. I couldn't test it on a real Windows ACL setup. Public API: unchanged. No further concerns.
Issue for this PR
Closes #67402
Type of change
What does this PR do?
When opening a project inside a directory whose parent folders deny access (for example, an isolated Windows user who can access
A/B/Cwithout access toAorB),ConfigDiscovery.discoverdies with an unhandledPlatformErrorand server requests fail with 500.FSUtil.upcalledfs.existswithout catchingisAccessDenied, unlikeFSUtil.resolveandFSUtil.readFileStringSafe(updated in #55817). CatchingisAccessDeniedinFSUtil.uptreats denied ancestor paths as absent so upward traversal continues across accessible directories, while non-permission I/O errors such asEIOstill fail.How did you verify your code works?
packages/core/test/util/fs-util.test.tscoveringEACCES(PermissionDenied),EPERM(Unknown), and fatalEIOfailures duringFSUtil.up.cd packages/core && bun run script/test.ts test/util/fs-util.test.ts --rerun-each 10 --randomize(60 pass, 0 fail)cd packages/util && bun run test && bun run typecheck && bun run typecheck:tsc(154 pass, 0 type errors)cd packages/core && bun run typecheck && bun run typecheck:tsc(0 type errors)oxlintandprettier --checkon both changed files (0 warnings/errors)Note: Real Windows NTFS ACL traversal was not run locally on macOS; the unit tests exercise Effect's
PermissionDenied/EPERMfailure paths directly.Screenshots / recordings
N/A (no UI changes).
Checklist
Added by the opencode bot (AI-generated).
Related: #63307, #53508