GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Fix hosted gem redirect breaking multi-line and conditional gem lines (#340) by mikolalysenko · Pull Request #637 · SocketDev/socket-patch Conversation
|
| Issue arm | Test | Without fix | With fix |
|---|---|---|---|
#340 multi-line (unit, 11 continuation shapes incl. CRLF, comment, =>, key:, \, brackets, paren form, heredoc) |
patch::redirect::tests::gemfile_multi_line_or_conditional_declaration_fails_closed |
FAILED (Gemfile rewritten with orphaned require: false) |
ok |
#340 conditional (unit, 11 modifier shapes incl. if::X, unless::X, if:x == …) |
same test | FAILED | ok |
| Control: lookalikes still rewrite with options kept | gemfile_single_line_declaration_lookalikes_still_rewrite |
ok | ok |
| Vendored shared-guard shapes | vendor::gem test block after the conditional assertion |
— | ok |
| #340 multi-line, real Bundler 4.0.17 / Ruby 3.3.6 | e2e_redirect_gem_build::gem_hosted_multi_line_declaration_is_refused_and_still_installs |
FAILED | ok |
| #340 conditional, real Bundler 4.0.17 / Ruby 3.3.6 | e2e_redirect_gem_build::gem_hosted_conditional_declaration_is_refused_and_still_installs |
FAILED | ok |
I got the red results by checking out main's crates/socket-patch-core/src with only the new tests applied. For 84a43d4, the if::FEATURE case was confirmed red against 369daa5's guard.
Local runs:
cargo clippy --workspace --all-features -- -D warnings: clean.cargo test --workspace --all-features --no-fail-fast (at 369daa5): 9726 passed, 12 failed. All 12 are permission-denial or write-failure simulations (covgap_commands_vendor *_state_write_failure_*, repair_*unremovable*, *write_failure*, relax_loop_must_not_traverse_symlinked_root, …). They can't fail as intended in this sandbox, which runs as root (uid 0), and none of them touch gem code. CI runs as non-root, and all of these pass there. At 84a43d4, the core lib tests (same 4 root-only failures) and 91 CLI gem tests were re-run.cargo fmt: main itself isn't rustfmt-clean (about 500 diffs) and CI doesn't gate on it, so this PR formats only its own hunks.🤖 Generated with Claude Code
https://claude.ai/code/session_015ZK1CuReoar7pKs2eZwepT
Note
Medium Risk
Changes Gemfile rewrite eligibility for hosted and vendored gem flows; incorrect classification could skip needed redirects or still break rare Gemfile shapes, but behavior is intentionally fail-closed with warnings.
Overview
Fixes #340: hosted gem redirect no longer rewrites gem lines whose declaration is not confined to a single safe line. Multi-line continuations, if/unless modifiers (including if::CONST), heredocs, and interpolated heredoc openers now fail closed with redirect_gem_unrecognized_declaration (detail names the reason) instead of producing broken Gemfiles or dropping conditions.
Adds shared gem_line_tail_blocks_edit, which scans the argument tail outside strings and comments for continuations, modifiers, and heredocs. The hosted rewriter calls it before moving a line into a source … do block; vendored Gemfile editing delegates the same structural rules via rest_blocks_edit, replacing weaker substring checks.
Unit tests cover refused shapes, lookalikes that still rewrite, and tail-parser edge cases. E2E e2e_redirect_gem_build gains drivers for multi-line, conditional, scoped-constant modifier, and heredoc fixtures (unchanged Gemfile/lock, no VEX, bundler still installs).
Reviewed by Cursor Bugbot for commit 464896d. Configure here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Assisted-by: Claude Code:claude-opus-5-5
Hosted scan rewrote a `gem` declaration that continued on the next line, leaving the continuation orphaned after the new source block so bundler refused the Gemfile. It also dropped `if`/`unless` modifiers, declaring the gem unconditionally. Both now skip the redirect with a redirect_gem_unrecognized_declaration warning and leave the Gemfile untouched. The check is shared with vendored mode, which also now catches continuations after `=>`, a key, `\` or an open bracket, and modifiers separated by tabs. Fixes #340 Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Stale Bugbot comment from a previous run.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Burn-down agent: Ready for review at
Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Codex follow-up review: correction pushed as The remaining interpolated-heredoc case is fixed. The shared hosted/vendor guard now refuses a possible Validation: 267 core tests and four native CLI tests passed, with five Ruby 3.4.10 / Bundler 4.0.15 fixture runs. Native cases cover colon-adjacent modifiers, plain and interpolated heredocs, and the original multiline/conditional declarations; they require a named refusal, unchanged files, zero redirects/VEX statements, and a successful native install. The actual-rewriter and native interpolation regressions both failed on the exact author head before this correction. Targeted Clippy passes with the existing macOS Ready to merge as-is from this review. 482 successful checks and 7 skipped; 12 workflows succeeded and one label-triggered Benchmarks workflow was skipped. Bugbot is clear on this commit; no unresolved review threads or new actionable findings. Ready for review has been restored. GitHub still requires the normal human approval before merge. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
`gem "x", "1.0.0" if::FEATURE` and `if:flag == ...` are `if` modifiers,
not hash keys, because nothing separates them from the preceding value.
The guard now counts `word:` as a key only where an argument can start
(after `,`, `(` or `{`) and never as `word::`. A heredoc opener is also
refused: its body follows on later lines, past the inserted `end`.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015ZK1CuReoar7pKs2eZwepT
|
Both findings from the Codex review of
All four shapes are added to The other agent run said it was working on the same fix. I checked that the branch had no new commits before pushing, so please build on Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
BugBot review Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Stale Bugbot comment from a previous run.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Cursor (@cursor) review Please review follow-up |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
✅ 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 464896d. Configure here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
A Gemfile line like `gem "a", "1"; gem "b", "2"` had its second declaration deleted when socket-patch redirected or vendored gem "a", because the rewrite replaces the whole line and the safety check did not know that `;` starts a new statement. The next frozen `bundle install` then failed. Such lines are now refused with a warning and left untouched. A declaration ending in a bare `;` (optionally followed by a comment) was refused as "continues on the next line" since #637. It is complete, so it is rewritten again, without the `;`. Fixes #826 Assisted-by: Claude Code:claude-opus-5-5
* Start fix for #826 Assisted-by: Claude Code:claude-opus-5-5 * Keep gem declarations sharing a line with ; A Gemfile line like `gem "a", "1"; gem "b", "2"` had its second declaration deleted when socket-patch redirected or vendored gem "a", because the rewrite replaces the whole line and the safety check did not know that `;` starts a new statement. The next frozen `bundle install` then failed. Such lines are now refused with a warning and left untouched. A declaration ending in a bare `;` (optionally followed by a comment) was refused as "continues on the next line" since #637. It is complete, so it is rewritten again, without the `;`. Fixes #826 Assisted-by: Claude Code:claude-opus-5-5 * Use the reported line shape in the ; e2e test The `;`-joined fixture had no version argument, so the old check already refused it as "unexpected tokens" and the test passed without the fix. Use `gem "x", "v"; gem "y", "v"` from #826, which the old code rewrote and lost the second gem. Assisted-by: Claude Code:claude-opus-5-5 * Port #878: route Gradle digests through helpers main is red: #646 added inline sha1/sha256 calls that #865's production_digests_go_through_the_helpers guard rejects. This ports the fix from #878 so this PR's coverage job can go green. It becomes a no-op once #878 lands. Assisted-by: Claude Code:claude-opus-5-5 --------- Co-authored-by: Claude <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Hosted gem redirect breaks a multi-linegem declaration (the Gemfile stops parsing) and drops a trailing if/unless modifier
There was an error while loading. Please reload this page.