Skip to content

Accept either unseen repository in the vendored Cargo real-Bazel flow - #2227

Merged
Mikola Lysenko (mikolalysenko) merged 2 commits into
mainfrom
fix/bazel-cargo-query-either-repo
Nov 25, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 2 commits into
mainfrom
fix/bazel-cargo-query-either-repo

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

A real-Bazel test of vendored Cargo no longer fails when Bazel names @platforms before the crate hub's repository.

Why

cargo::vendored_from_cargo_with_config comments out the line that the scan wrote in .bazelignore and expects bazel cquery //... and bazel query 'deps(//...)' to fail on a repository that the main repository does not see. Its helper looked for the hub's repository (@crates__...) alone.

The build file that cargo-bazel writes into the committed copy names @platforms as well, and Bazel reports the first unseen repository it meets. On the Linux runners with Bazel 9.3.2 the query named @platforms in three recent runs of the cargo / bazel (9.3.2, e9) job, on two pull requests that do not change this flow, and the flow failed on its own check:

ERROR: Evaluation of query "deps(//...)" failed: ... No repository visible as '@platforms' from main repository

What changes

  • The helper reads the repository's name out of Bazel's message and takes it when the message is about the main repository's view and the name is platforms or one of the crate hub's. Anything else is a different failure.
  • A test without Bazel holds that check to the two messages that were seen and to three it must not take.
  • docs/ecosystems.md (the section on the build file in a vendored crate) said the two commands end on the dependency's repository. It now says they can end on @platforms as well.

Tests and one docs sentence: nothing a command does changes.

Code review

Six findings; four are applied in the second commit.

  • Applied: the docs sentence; the module docs and the comment at the call; the message is now matched with its ending (from main repository), so the same words about another repository's view do not pass; the two names are no longer a format string with a quote hidden in one of them.
  • Not applied: holding cquery to the hub's name alone. It was query that named @platforms in the three runs, but nothing fixes the order for cquery either, and the flow is about the command failing on a repository the main repository does not see.
  • Not applied: making the order deterministic (--keep_going, or reading the names out of the rendered build file). It is a larger change to a flow that takes minutes to run on each of three Bazel releases; the accepted names are the two the rendered file was seen to produce.

How it was checked

  • The first commit is also on another open pull request, where the Cargo jobs pass on Bazel 9.3.2, 8.8.2 and 7.7.2.
  • Locally: rustfmt --check on the file, cargo clippy --locked -p socket-patch-cli --test e2e_bazel_build -- -D warnings, and the new test without Bazel.
  • Not run locally: the real-Bazel flow. CI runs it here once the pull request is out of draft. The failure is intermittent, so one green run shows that the new check accepts what Bazel prints, not that the old one would have failed.

Generated by Claude Code

…gnore line

`cargo::vendored_from_cargo_with_config` comments out the line the scan
wrote in `.bazelignore` and expects `bazel cquery //...` and
`bazel query 'deps(//...)'` to fail on a repository that the main
repository does not see. It looked for the hub's repository
(`@crates__...`) alone. The build file that cargo-bazel writes into the
committed copy names `@platforms` as well, and Bazel reports the first one
it meets: on a Linux runner with Bazel 9.3.2 the query named `@platforms`
and the flow failed on its own check.

The flow now takes either name for that failure. Test only: nothing the
command does changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The check of the commands that fail once the ignore line is commented out
now reads the name out of Bazel's message and takes it only when the
message is about the main repository's view: `platforms`, or a repository
of the crate hub. The same words about another repository's view, or
about another name, are a different failure and no longer pass for the
expected one. A test without Bazel holds the check to the two messages
that were seen and to three it must not take.

The module docs, the comment at the call and the section on the build
file in a vendored crate said the commands end on the dependency's
repository alone. They now name `platforms` as well, which is what a
user who comments the line out can see.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review November 24, 2026 22:56
@cursor

cursor Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Test-only assertion logic and a docs clarification; production CLI paths are untouched.

Overview
The vendored Cargo real-Bazel flow expected bazel cquery //... and bazel query 'deps(//...)' to fail only when stderr mentioned a @crates__… hub repo. Bazel 9.3.2 can instead report @platforms first (both appear in the rendered BUILD.bazel), which made CI fail intermittently.

The e2e helper now parses the from main repository message and treats failure as valid only when the unseen name is platforms or a crates__* hub repo; other wording or repos still count as a different failure. A small unit test locks that behavior without invoking Bazel. docs/ecosystems.md notes either repository name can appear in those errors.

No socket-patch command behavior changes—only the test assertion and documentation.

Reviewed by Cursor Bugbot for commit 17352ac. Configure here.

@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Nov 24, 2026
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[agent] PR shepherd: review brief for the approver

What it does
Fixes an intermittent failure of the real-Bazel vendored Cargo test. When the .bazelignore line is commented out, Bazel fails on the first repository it can't see, and that's sometimes @platforms instead of the crate hub's @crates__.... The test helper now accepts either name, and only when the message is about the main repository's view. Test code and one docs sentence only. No product behavior changes.

Risk
Low. Only test code and docs change. The matcher is strict: it requires the from main repository ending and accepts only platforms or a crates__ name. So it can't hide an unrelated query failure.

Look here

Verified

Changes I made
None.

Open questions
None.


Generated by Claude Code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[agent] Reviewed; no major findings.

Merged via the queue into main with commit 15b2897 Nov 25, 2026
89 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the fix/bazel-cargo-query-either-repo branch November 25, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants