Skip to content

fix(opencode): normalise windows permission path patterns through realpath - #47951

Closed
CannonRS wants to merge 1 commit into
anomalyco:devfrom
mQorva:expand-windows-paths
Closed

CannonRS wants to merge 1 commit into
anomalyco:devfrom
mQorva:expand-windows-paths

Conversation

@CannonRS

@CannonRS CannonRS commented Sep 8, 2026

Copy link
Copy Markdown

Issue for this PR

Fixes #36681

Type of change

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

What does this PR do?

Permission whitelist entries written as absolute Windows paths were never
compared against the runtime's normalised path form, so a fully-specified
external_directory allow block still prompted on every external read.

Permission.expand() expandes ~/…, $HOME/… and keeps the literal string for
drive-letter patterns. The runtime (external-directory.ts) canonicalises ask
targets on Windows via FSUtil.normalizePathPattern — which resolves symlinks
and junctions (e.g. ~/.claude resolving to ~/.codex) and normalises
separators. A config entry such as C:\Users\User\.config\opencode therefore
never string-matched the C:\Users\…\config\* request glob, so the gate fell
through to the ask default: the documented allow block silently did not apply.

This change sends the same realpath pass over absolute Windows whitelist
patterns in expand(), so config patterns and request globs collapse onto the
same canonical prefix. Non-path patterns (ls, *.env, relative paths) are
left untouched; the drive-letter guard keeps the normalisation scoped to
absolute Windows paths.

How did you verify your code works?

  • New Permission.expand tests cover untouched non-path patterns, tilde/$HOME
    expansion, and (on Windows) drive-prefix + trailing-wildcard survival through
    the realpath pass.
  • Updated fromConfig tilde/$HOME expectations to be platform-tolerant
    (Windows requests the normalised form).
  • bun typecheck and bun test test/permission/ in packages/opencode:
    88 pass / 0 fail.

Screenshots / recordings

N/A — not a UI change.

Fork

Checklist

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

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Windows path references and permissions on external directory path not working

1 participant