Repository navigation
Fix Windows nightly test failures and absolute --patch-dir bound - #2049
Conversation
The scheduled CI run has been red on main for five nights. Its `test (windows-latest, 1|2)` legs (nightly-only) fail seven tests that pass on Linux and macOS, all from test-side assumptions about Unix paths: - an_absolute_patch_dir_inside_the_repository_is_read built its package.json with format!, so the Windows path's backslashes were invalid JSON escapes; build it with serde_json instead. - five assertions matched `/`-separated substrings in user-facing detail text that Windows prints with `\`; compare after mapping `\` to `/`. - pnpm_workspace_file_above_the_repository_fails_closed expected the canonical `\\?\` path, but governing_workspace_file deliberately strips that prefix; expect without_verbatim_prefix(file). No production code changes; every assertion still checks the same path on every OS. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeRDbxjatib28cpxPqQ
|
bugbot run Generated by Claude Code |
On Windows the bound's repository root is canonical (`\\?\C:\...`) while a script names its patch directory as users type it (`C:\...`), and Path::starts_with treats the verbatim and plain disk prefixes as different. Every absolute in-repo `--patch-dir` was reported as outside the repository, protecting every npm package. Compare both sides without the verbatim prefix, and make the test spell the directory the way a user does (quoted, unprefixed). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeRDbxjatib28cpxPqQ
|
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 c40cda6. Configure here.
|
In the Windows dispatch run 42772455462, The same legs failed on main in last night's scheduled run 42763778797 (main @ c751724). They failed on all three OSes there: The failing assertion is I'm leaving it out of this PR. It's the next CI-janitor target. This PR's own target is the Generated by Claude Code |
|
Labeled Ready for review by the burn-down agent.
Generated by Claude Code |
Final review briefWhat it does. Fixes the 7 tests that fail only on the nightly Windows Risk: low. One production line, a no-op on Unix. On Windows it makes an in-repo absolute Look here
Verified
Changes I made. None. Open questions. None blocking. The description lists two follow-ups it chose not to do: OS separators in the hosted engine's detail text, and a shared Auto-merge (squash) is armed, so approving sends this straight to the merge queue. Generated by Claude Code |
Problem
Scheduled
CIon main has failed 5 nights running (11-06 → 11-10). On the latest run, 42763778797 (main @ c751724), the only failing jobs aretest (windows-latest, 1)andtest (windows-latest, 2). Those legs run only at night (see #1720), so PR and merge-queue CI never catch these failures. Both legs use--no-fail-fast, so this is the full set:patch::user_patches::tests::an_absolute_patch_dir_inside_the_repository_is_readformat!, soC:\...became invalid JSON escapes. The fix below also found a real bug behind this test.patch::user_patches::tests::the_repository_bound_holds_for_workspace_runs_onlyends_with("fixes/left-pad+1.3.0.patch")on a\-separated pathutils::cargo_build_cache::tests::a_config_above_the_repository_is_named_when_its_target_dir_is_unreadcontains(".cargo/config.toml")checked against.cargo\config.tomlutils::repo_root::upward_tests::pnpm_workspace_file_above_the_repository_fails_closed\\?\C:\...path, butgoverning_workspace_filedeliberately returns it throughwithout_verbatim_prefixvex::discover::user_patched::tests::patch_package_patches_mark_yarn_classic_vlt_and_npm_pins/substring checked againstpatches\left-pad+1.3.0.patchvex::discover::user_patched::tests::workspace_member_patches_agree_with_the_consent_gatepackages/achecked againstpackages\a\package.jsonhosted_memory_engine::user_patched_npm_packages_are_never_pinned(cli)Root cause
/separators, unescaped JSON, and\\?\-prefixed expectations.Bound::outside(user_patches.rs) compares the path against the canonical repo root, which on Windows is\\?\C:\proj. A script's--patch-dir C:\proj\fixesis written the way users type it, andPath::starts_withtreats theVerbatimDiskandDiskprefixes as different. So on Windows every absolute in-repo--patch-dirwas reported as outside the repository, and every npm package was protected. The old test passed a\\?\path, which no real package.json contains.Fix
Bound::outsidenow compares both sides throughpnpm_workspace::without_verbatim_prefix. This changes nothing on Unix.--patch-dirtest now spells the directory the way a user does: unprefixed, quoted, and built throughserde_jsonso the backslashes are escaped.\to/.without_verbatim_prefix(file).No assertion is weaker.
Proof
cargo test -p socket-patch-core --lib -- patch::user_patches vex::discover::user_patched utils::repo_root utils::cargo_build_cache: 73 passed.cargo test -p socket-patch-cli --test hosted_memory_engine --test user_patches: 57 passed.rustfmt --checkon the touched files is clean.os=windowson this head, 42772455462, passedtest (windows-latest, 1)andtest (windows-latest, 2). Its only failures are themode_migration_vlte2e legs, which fail the same way on main's nightly on every OS and are not this PR's (see the comment below).Review findings not fixed
/code-review high:user_patch_conflictdetail text uses OS separators (Path::display). Production servers run Linux, so changing how in-memory sources are rendered is a larger change and out of scope here. Worth a follow-up.slashedhelper. The.replace('\\', "/")call is repeated inline, and there is no shared helper for it. Core has no test-util module that all of these tests share. That refactor is left out of a CI fix.Where tests run
No tests were removed or moved.
🤖 Generated with Claude Code
https://claude.ai/code/session_011f9aeRDbxjatib28cpxPqQ
Note
Medium Risk
Changes workspace-bound patch discovery on Windows (consent gate / user-patch conflicts); incorrect comparison previously over-protected npm packages.
Overview
Fixes Windows nightly CI failures and a production bug where in-repo absolute
patch-package --patch-dirpaths were treated as outside the git repository.Production:
Bound::outsideinuser_patches.rsnow strips Windows\\?\verbatim prefixes on both sides beforestarts_with, so user-typedC:\repo\fixesmatches canonical\\?\C:\repo. Unix behavior is unchanged.Tests: Assertions that assumed
/separators or\\?\paths now normalize with.replace('\\', "/")or expectwithout_verbatim_prefix. The absolute--patch-dirtest buildspackage.jsonviaserde_jsonwith a quoted, user-style path so JSON escaping is valid on Windows.Reviewed by Cursor Bugbot for commit c40cda6. Configure here.
Generated by Claude Code