fix(review): Windows cross-drive annotation paths escape the workspace guard#1117
Open
BenNewman100 wants to merge 1 commit into
Open
fix(review): Windows cross-drive annotation paths escape the workspace guard#1117BenNewman100 wants to merge 1 commit into
BenNewman100 wants to merge 1 commit into
Conversation
- path.relative returns the target's absolute path when base and target are on different Windows drives; normalizeAgentPath's escape guard only checked ".." and "/" prefixes, so such results slipped through and were glued onto the repo label (e.g. "api/L:/checkout/src/file.ts") - extract the guard into isRepoRelative and reject drive-letter-prefixed results at all three call sites - fixes the annotation-path assertions in review-workspace.test.ts, which failed on Windows whenever the checkout and %TEMP% live on different drives; add a platform-independent unit test for the new guard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
normalizeAgentPathinpackages/shared/review-workspace.tsguards itspath.relative()results withstartsWith("..")/startsWith("/")checks. On Windows,path.relative()cannot relativize across drives and returns the target's absolute path instead. After backslash normalization that result looks likeL:/...— it slips past both checks and gets prefixed with the repo label, producing annotation paths likeapi/L:/checkout/src/file.ts.Practical symptom: the existing test "normalizes agent annotation paths to workspace-prefixed paths" fails on a pristine checkout for any Windows contributor whose repo lives on a different drive than
%TEMP%— the workspace fixtures are created undertmpdir(), and the relative input"src/file.ts"resolves against the checkout's cwd, sorelative()spans two drives.Fix
Extract the guard into
isRepoRelative()and additionally reject drive-letter-prefixed results (/^[A-Za-z]:/). Applied at all three call sites innormalizeAgentPath. Pure string logic, so behavior is identical across platforms.Testing
%TEMP%on different drives:bun test packages/server/review-workspace.test.ts— the annotation-path test now passes (it failed before this change); the file's remaining failures on that box are pre-existing environment issues, identical onmainisRepoRelativecovering the cross-drive shapebun run typecheck— all projects pass