Repository navigation
Fix macOS go.work member match through ./x/../app - #1411
Conversation
same_dir_key canonicalized a go.work `use` directory and fell back to lexical folding only when canonicalize failed. `./x/../app` with no `x` directory fails to canonicalize, so it kept the unresolved temp prefix while the project root resolved through symlinks. On macOS, where the temp dir lives under the /var -> /private/var symlink, the two never matched and go_work_that_does_not_use_the_project_makes_ the_replace_inert failed in every macOS `test` leg (full-scope, workflow_dispatch and nightly CI). Fold lexically first, as go's filepath.Join does, then resolve symlinks on the folded path. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AKt88ZvtcGWp1UvdvmTerp
|
bugbot run Generated by Claude Code |
Review follow-up. Folding every key lexically first also folded the project root, so a root spelled `link/../app` named a different directory than the one being patched. Canonicalize first as before, and fold-then-resolve only a path that fails to canonicalize. Add a unix test that reaches the workspace through a symlink, so Linux PR CI covers the macOS /var -> /private/var case. It fails on the previous implementation. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AKt88ZvtcGWp1UvdvmTerp
|
bugbot run Generated by Claude Code |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit f37a41b. Configure here.
|
Ready for review (burn-down agent)
Generated by Claude Code |
Final review briefWhat it does: When go.work lists a member as Risk: low. One fallback branch in one helper changes; paths that already canonicalize behave exactly as before. Look here:
Verified: read the full diff. The test fails without the fix: the old fallback leaves Changes I made: none. Open questions: none. Auto-merge is armed, so approving sends it straight to the merge queue. Generated by Claude Code |
Problem
vendor::go_consumer_sync::tests::go_work_that_does_not_use_the_project_makes_the_replace_inert(added in #1393) fails deterministically on macOS:Evidence: run 38191238691, job
test (macos-latest, 1). It's a full-scopeworkflow_dispatchof #1407, which doesn't touch socket-patch-core: 6336 passed, 1 failed.The macOS
testlegs run only on schedule,workflow_dispatchorCI_SCOPE=full. That's why PR and merge-queue CI stayed green after #1393 merged. Expected impact if this isn't fixed:CI_SCOPEis set tofull.Root cause
same_dir_keycalledcanonicalizeon the joinedusepath and fell back to lexical folding only when that call failed.ws/x/../appwith noxdirectory fails to canonicalize, so its key kept the unresolved/var/...prefix. The project root does exist and canonicalized to/private/var/.... On macOS$TMPDIRsits under the/var -> /private/varsymlink, so the two keys never matched and the project read as "not a member" of go.work.Fix
`same_dir_key` still canonicalizes first, so the project root and any existing `use` path resolve exactly as before. When the direct canonicalize fails, it now folds the path lexically, as go's `filepath.Join` does for `./x/../app`, and canonicalizes the folded path before falling back to it. Before, the fallback compared the unresolved lexical path.
I also added the unix test `go_work_member_matches_through_a_symlinked_workspace`. It reaches the workspace through a symlink, so Linux PR CI covers the macOS `/var` case. It fails on the previous implementation.
`/code-review high` follow-up: the first version folded every key before resolving it, which would have regressed a project root spelled `link/../app`. Fixed in f37a41b. Findings not taken here:
Proof
I reproduced it on Linux by pointing
TMPDIRat a symlink to a real directory:before:
TMPDIR=<symlink> cargo test -p socket-patch-core --lib go_consumer_syncgives8 passed; 1 failed, with the same./x/../appassertion.after:
cargo test -p socket-patch-core --lib go_gives437 passed; 0 failed, both withTMPDIR=<symlink>and with the default TMPDIR.cargo clippy --locked -p socket-patch-core --all-features -- -D warningsis clean, and so isrustfmt --checkon the touched file.the full core lib under the symlinked TMPDIR shows 4 other failures. They fail the same way on unmodified main, because the sandbox runs as root and those tests depend on permission denials. They're unrelated to this change.
the new test fails on the old
same_dir_keyon Linux (./x/../appassertion) and passes with the fix.macOS: full-scope dispatch 38194345200 on f37a41b passes
test (macos-latest, 1)and(macos-latest, 2), and both Windows legs.No tests removed or moved. #1403 also touches this file, but only around line 280, so the two diffs don't overlap.
🤖 Generated with Claude Code
https://claude.ai/code/session_01AKt88ZvtcGWp1UvdvmTerp
Generated by Claude Code