Repository navigation
Fix hosted cargo pin of registry = "crates-io" (#386) - #1412
Conversation
Assisted-by: Claude Code:claude-opus-5-5
Hosted cargo scan skipped a dependency declared with `registry = "crates-io"`, warning that it was pinned to another registry. `crates-io` is Cargo's built-in name for crates.io, so the declaration resolves exactly like one with no registry key, and the project kept building the unpatched crate while scan reported success. The Cargo.toml pin now overwrites a `crates-io` value in place, the same way it supersedes an earlier socket-patch pin, in both the inline-table and the [dependencies.x] table spellings. Removing the patch drops the pin, which leaves the declaration without the redundant key; cargo resolves it the same way. Fixes #386 Assisted-by: Claude Code:claude-opus-5-5
The vendored-to-hosted takeover test used `registry = "crates-io"` as a Cargo.toml spelling the hosted rewriter refuses. Hosted mode now pins that spelling, so the case would no longer exercise the refusal. Use a multi-line inline table instead, which hosted mode still refuses (#757) and vendored mode accepts. Refs #386 Assisted-by: Claude Code:claude-opus-5-5
Removing a hosted cargo patch dropped a table-form pin line whole, including any comment the user had on it. Since the pin can now overwrite a user's `registry = "crates-io"` line in place, that comment was the user's. The restore now keeps it on its own line. Also refresh the doc comments that still said only socket-patch pins are overwritten, and note that a restored crates-io declaration comes back without the redundant registry key. Refs #386 Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
A comment kept from a table-form pin line lost its carriage return on a CRLF Cargo.toml, so remove left that one line ending in LF. The comment is now sliced from the raw line, keeping its `\r`. Refs #386 Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review 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 c2b3f89. Configure here.
|
Ready for review (burn-down agent)
Generated by Claude Code |
Final review briefWhat it does Risk: low. It's a one-predicate change in the hosted Cargo.toml planner, and it only affects the literal value Look here
Verified
Changes I made: none. Open questions: none. The contrived triple-quoted spellings in the PR description fail closed and are deferred to #757. Auto-merge is armed, so approving sends this straight to the merge queue. Generated by Claude Code |
LLM Description written by Claude Code:claude-opus-5-5
Fixes #386
Summary
scan --mode hostednow pins a crates.io dependency declared with an explicitregistry = "crates-io", in both the inline-table and the[dependencies.x]table spellings, instead of skipping it as "pinned to another registry".Root cause
The hosted Cargo.toml planner (
plan_cargo_tomlinpatch/redirect/mod.rs) let aregistry = …value through only when it was our current pin or a stalesocket-patch-<uuid>pin. Every other value was refused, includingcrates-io, Cargo's built-in name for crates.io. Cargo resolves that declaration exactly like one with noregistrykey, so hosted mode skipped a dependency it is built to redirect. It reportedredirected: 0and exited 0 withstatus: successwhile the project kept building the unpatched crate.Changes
is_repinnable_registry_name:crates-iois now overwritten in place, the same way a superseded socket-patch pin is, in both the table and inline arms. Any other registry name is still refused.remove): as for every pin, the original spelling isn't recorded, so the declaration comes back without the redundantregistry = "crates-io"key (the inline shorthand collapses toname = "1.0.4"). Cargo resolves it the same way and the lock is unchanged. This is documented in the module doc.unpin_linenow keeps a trailing comment from a table-form pin line instead of dropping it with the line.mode_migration_cargo::takeover_over_unrewritable_spelling_keeps_vendored(Cargo vendored → hosted takeover un-vendors a crate before hosted mode refuses its Cargo.toml spelling (dotted keys, single quotes, registry = "crates-io"), leaving it unpatched, while --dry-run previews redirected: 1 #1020) usedregistry = "crates-io"as its example of a refused spelling. It now uses a multi-line inline table (Hosted cargo redirect refuses a dependency whose inline table has a multi-line features array, because it plans Cargo.toml pins with a line scanner #757), which hosted mode still refuses.Tests (red → green)
redirect::tests::cargo_explicit_crates_io_registry_is_pinned_in_place(inline, single-quoted + comment, table, renamed table with quoted key; idempotent re-run)redirect_cargo_toml_dep_unrewritable … pinned to another registry ("crates-io")e2e_redirect_cargo_shapes::cargo_hosted_explicit_crates_io_registry_is_pinned(real cargo: scan, fresh--lockedbuild links the patched crate, VEX, remove)skipped … no lockfile entry pinning it could be rewrittenupstream::cargo::tests::table_form_line_keeps_its_commentLocal runs on 46af5c2 (c2b3f89 adds the Bugbot CRLF fix; upstream::cargo tests, core clippy and e2e_redirect_cargo_shapes re-run green):
cargo fmt --all -- --check: cleancargo clippy --workspace --all-features -- -D warnings: cleancargo test -p socket-patch-core --all-features: 6321 passed, 4 failed. The failures arecopy_tree::relax_loop_must_not_traverse_symlinked_root,vlt_heal::an_unremovable_hidden_lock_keeps_every_store_entry,pypi_poetry::wire_write_failure…andpypi_requirements::wire_failure_rolls_back…. All four are chmod-based tests that fail because the agent sandbox runs as root, and they're unrelated (see Go go.work audit: false NotAMember for a use path through a missing dir on macOS (breaks macOS test job) #1409 for the same note).SOCKET_PATCH_CARGO_E2E_REQUIRED=1 cargo test -p socket-patch-cli --all-features --test e2e_redirect_cargo_shapes --test mode_migration_cargo --test e2e_redirect_cargo_build: 31 / 29 / 22 passedcargo test -p socket-patch-cli --lib --test in_process_cargo_apply: okcargo test --workspacecouldn't finish locally because the sandbox ran out of disk linking ~100 CLI test binaries. CI covers it.npm/,pypi/andgem/just dispatch to the binary./code-review high: findings not fixed
registry = '''crates-io'''or aregistry = '…'string inside a feature name defeats the line regex. The planned manifest then fails validation and the dep is refused, so it fails closed and is never mis-pinned. Both are contrived spellings; the general fix is Hosted cargo redirect refuses a dependency whose inline table has a multi-line features array, because it plans Cargo.toml pins with a line scanner #757's move ontotoml_edit.restoredoverride isn't CRLF-converted in the e2e harness. No CRLF shape uses it.restored: vec[]on everyShapeliteral matches the harness's existing explicit-field style.Not in scope
#757 (multi-line inline tables) touches the same planner but has a different cause: the planner reads one line per inline table. It needs the planner moved onto
toml_editand the upstream restore taught multi-line edits.🤖 Generated with Claude Code
Generated by Claude Code