Repository navigation
fix(core): resolve sandbox Location paths with the sandbox's path rules - #65996
opencodejr[bot] wants to merge 1 commit into
Conversation
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.
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
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. |
There was a problem hiding this comment.
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.
|
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. |
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 runscd /outside-wt.FileAccess.placeresolved every path in the Location's own environment with the host'sresolvePath, which uses the host'spath.resolve. On a Windows server that turns the sandbox path/outside-wtintoC:\outside-wt. The in-memory sandbox driver keys that as/C:\outside-wt, so the stat returns NotFound andcdfails 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 withenvironment.path.resolve. Otherwise keepresolvePath, 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.tsin packages/core: 169 pass, 0 fail (Linux).tsc --noEmit -p tsconfig.jsonin packages/core: no errors in file-access.ts. The package'stypecheckscript could not run in the sandbox ("Script not found "check"").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 pathsfailed 3 runs in a row ondev.5b66287(first failing: run 11823)8c80affOpened by the CI fix job: it does not merge or push to
dev.