Repository navigation
Fix nightly gem e2e: attribute nested Gemfile source blocks - #1999
Mikola Lysenko (mikolalysenko) wants to merge 1 commit into
Conversation
The nightly e2e-extended gem legs on bundler 1.17.3 and 2.1.4 fail in gem_hosted_redirect_keeps_a_crlf_gemfile_crlf (#1997). The hosted redirect wraps a gem the user declared in their own `source "..." do` block in a Socket block nested inside it. Bundler <= 2.1 writes one merged GEM section, so discovery attributes the gem only through the Gemfile source block that pins it. The Gemfile reader ignored nested blocks and gave the gem to the outer upstream block, so rollback refused with hosted_wiring_contested / patched_ref_unattributable. Track open `source ... do` blocks as a stack and scope each gem to the innermost one, as bundler's Dsl#with_source does. The same reader backs ledger liveness and manifest_source_pins, which now see the nested Socket pin too. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeSZhUZfmB5eQt427Fy
|
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 9a62f63. Configure here.
|
Labeled Ready for review by the burn-down agent.
Generated by Claude Code |
Final review briefWhat it does: The Gemfile Risk: low. One file, a small parser change, with the opener parsing moved unchanged into a helper. Attribution still needs the DEPENDENCIES Look here:
Verified:
Changes I made: none. Open questions: none that block. One note, not new to this PR: a non- Auto-merge is armed: approving sends this straight to the merge queue. Generated by Claude Code |
Fixes #1997.
Problem
The nightly
CIschedule run on main is red on twoe2e-extendedgem legs, and has been since #1961 added the CRLF source-block arm:e2e-extended (ubuntu-latest, e2e_redirect_gem_build e2e_vendor_gem_build, 3.1, 2.1.4), job 125750207261e2e-extended (ubuntu-latest, e2e_redirect_gem_build e2e_vendor_gem_build, 3.1, 1.17.3), job 125750207277Both fail only in
gem_hosted_redirect_keeps_a_crlf_gemfile_crlf, in thecrlf-gemfile-source-blockarm. Rollback exits 1 withhosted_wiring_contested/patched_ref_unattributable: "GEM section lists 2 remotes (a merged multi-source lock), and no gem in it is source-pinned to Socket patch …". The failure is deterministic and I reproduced it locally on bundler 2.1.4. PR CI runs only the bundler 4.0.21 leg, so only the nightly hits it.#1995 tried a test-only fix that skipped this arm on bundler < 2.2. It was closed unmerged, so this PR does the product fix, option 1 in #1997.
Root cause
The redirect leaves this Gemfile and lock (captured from the failing run on bundler 2.1.4):
Bundler <= 2.1 merges every rubygems source into one GEM section. Discovery then attributes a gem in that section only when DEPENDENCIES marks it
!and the Gemfile declares it inside asource … doblock for that Socket remote.parse_source_block_declsinvex/discover/gem.rsdidn't handle nested blocks: inside the user's outer block it skipped the innersource … doline and gave the gem to the outer upstream URL. So no gem matched the Socket remote, and rollback refused. Bundler itself scopes a gem to the innermost block (Dsl#with_source).Fix
The reader now keeps the open
source … doblocks on a stack. Eachgemline belongs to the innermost block, andendcloses the innermost one. I moved the opener parsing unchanged intosource_block_opener.Three callers use this grammar, and all of them now see a nested Socket block:
gemfile_source_block_pins, which ledger liveness uses;manifest_source_pins, which the rollout recorded view uses.For the redirect's own output this is more correct: before, a nested Socket pin was invisible to all three. The safeguards are unchanged. The gem still needs the DEPENDENCIES
!, a block naming that exact remote, and no other source declaring it.Proof
merged_section_nested_source_block_is_attributed_innermost. A nested Socket block attributes the gem with LF and with CRLF endings. The inverted nesting, with another source innermost, is stillpatched_ref_unattributable.source_block_grammargains a nested case: outer, inner, then outer again after the innerend.--ignored:cargo test -p socket-patch-core --lib: 7098 passed. Four tests fail the same way on unmodified main when run as root in this container (permission tests):relax_loop_must_not_traverse_symlinked_root,an_unremovable_hidden_lock_keeps_every_store_entry, and twowire_*rollback tests. They are unrelated to this change.cargo clippy -p socket-patch-core --all-targetsreports nothing in the touched file.workflow_dispatchof CI) confirms it.Where tests run
No test is removed or moved. The failing arm stays in the nightly e2e-extended legs on every bundler era.
https://claude.ai/code/session_011f9aeSZhUZfmB5eQt427Fy
Generated by Claude Code