Skip to content

fix(util): skip access-denied paths during FSUtil.up traversal - #67564

Open
SomSamantray wants to merge 2 commits into
anomalyco:devfrom
SomSamantray:skip-denied-ancestors
Open

SomSamantray wants to merge 2 commits into
anomalyco:devfrom
SomSamantray:skip-denied-ancestors

Conversation

@SomSamantray

@SomSamantray SomSamantray commented Dec 1, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #67402

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

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/C without access to A or B), ConfigDiscovery.discover dies with an unhandled PlatformError and server requests fail with 500.

FSUtil.up called fs.exists without catching isAccessDenied, unlike FSUtil.resolve and FSUtil.readFileStringSafe (updated in #55817). Catching isAccessDenied in FSUtil.up treats denied ancestor paths as absent so upward traversal continues across accessible directories, while non-permission I/O errors such as EIO still fail.

How did you verify your code works?

  • Added unit tests in packages/core/test/util/fs-util.test.ts covering EACCES (PermissionDenied), EPERM (Unknown), and fatal EIO failures during FSUtil.up.
  • Verified the new tests fail before the change and pass after:
    • 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)
    • oxlint and prettier --check on 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/EPERM failure paths directly.

Screenshots / recordings

N/A (no UI changes).

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #63307, #53508

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Related: #63307, #53508

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

This branch has not been deployed

No deployments
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.

Hierarchical Permissions Break Discovery on Windows

1 participant