Skip to content

fix(core): resolve sandbox Location paths with the sandbox's path rules - #65996

Closed
opencodejr[bot] wants to merge 1 commit into
devfrom
opencodejr/ci-fix-45334668320
Closed

opencodejr[bot] wants to merge 1 commit into
devfrom
opencodejr/ci-fix-45334668320

Conversation

@opencodejr

@opencodejr opencodejr Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

What failed

check-test / unit (windows): CdTool > exempts host-local project worktrees from external_directory, but not sandbox paths (packages/core/test/tool-cd.test.ts).

Root cause

The test's second half boots a sandboxed workspace Location (/workspace) and runs cd /outside-wt. FileAccess.place resolved every path in the Location's own environment with the host's resolvePath, which uses the host's path.resolve. On a Windows server that turns the sandbox path /outside-wt into C:\outside-wt. The in-memory sandbox driver keys that as /C:\outside-wt, so the stat returns NotFound and cd fails with "Working directory does not exist". This is a real product bug: on a Windows host, paths typed in a sandboxed Location resolve with win32 rules. It only shows on Windows because POSIX and host rules are the same on Linux and macOS. The intermittent history is most likely Windows runs that skipped core tests through the affected-packages filter, not real flakiness (not confirmed: the CI logs need a sign-in). The test was added in 6d04312 (cd tool); the commit flagged as the culprit (#65917) is unrelated.

Fix

When the Location's environment doesn't host the server and has its own path rules (sandboxes use posix), resolve with environment.path.resolve. Otherwise keep resolvePath, so host-local behaviour is unchanged. Side effect: in a sandboxed Location, ~ is no longer expanded to the server's home directory.

Verification

  • bun test test/tool-cd.test.ts test/environments.test.ts test/file-access*.test.ts test/tool-shell-target-environment.test.ts test/tool-read*.test.ts test/tool-edit.test.ts in packages/core: 169 pass, 0 fail (Linux).
  • tsc --noEmit -p tsconfig.json in packages/core: no errors in file-access.ts. The package's typecheck script could not run in the sandbox ("Script not found "check"").
  • The Windows-only path could not run here. The reasoning is that path.win32.resolve("/workspace", "/outside-wt") gives a drive-rooted path, which the posix memory driver cannot find.

CI failure: check-test / unit (windows) / CdTool > exempts host-local project worktrees from external_directory, but not sandbox paths failed 3 runs in a row on dev.

  • Failing run: run 11839 at 5b66287 (first failing: run 11823)
  • Last green run: run 11818 at 8c80aff
  • Culprit: no single commit (it looks flaky)

Opened by the CI fix job: it does not merge or push to dev.

FileAccess resolved paths in a sandboxed workspace Location with the host's
path.resolve, so on a Windows server /outside-wt became C:\outside-wt and
the sandbox could not find it. Use the environment's own path rules when it
does not host the server. Fixes the Windows failure in the CdTool worktree
exemption test.
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Nov 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 72 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I couldn't verify this on Windows, but it looks right. Sandbox environments (Environment.workspace) are the only ones that set their own path rules, so the new branch applies only to sandboxed Locations. Host-local resolution, including ~ expansion, is unchanged. The closest tests pass on Linux (tool-cd, environments, file-access*), and tsc is clean. I couldn't reproduce the Windows failure from Linux: forcing win32 path rules there also breaks host-local paths.

Public API: unchanged.

One non-blocking note: the rest of FileAccess.resolve still uses the host's path for a sandboxed Location. That covers path.resolve(location.project.directory), path.relative and path.parse(...).root. On a Windows server, worktree would become C:\workspace, so a sandbox path like /workspace/x might not count as inside the worktree. It would then be treated as an external directory. It may be worth using the same environment.path rules there, now or in a follow-up.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 72-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Nov 27, 2026
@github-actions github-actions Bot closed this Nov 27, 2026
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.

0 participants