Skip to content

handle elided name in git package ID specs#253

Open
pushrax wants to merge 2 commits into
rust-secure-code:masterfrom
pushrax:master
Open

handle elided name in git package ID specs#253
pushrax wants to merge 2 commits into
rust-secure-code:masterfrom
pushrax:master

Conversation

@pushrax
Copy link
Copy Markdown

@pushrax pushrax commented May 12, 2026

Per the package ID grammar, the suffix after # is ( pkgname | semver ), so a bare semver with no name@ prefix is valid for any source, not just path.

Cargo emits this form for git deps whose crate name matches the repo's last URL path segment (e.g. git+https://.../rayon#1.11.0), which previously panicked on the missing @.

Grammar reference:
https://doc.rust-lang.org/cargo/reference/pkgid-spec.html#package-id-specifications-1

Per the package ID grammar, the suffix after `#` is `( pkgname | semver )`,
so a bare semver with no `name@` prefix is valid for any source, not
just `path`.

Cargo emits this form for git deps whose crate name matches the repo's
last URL path segment (e.g. `git+https://.../rayon#1.11.0`), which
previously panicked on the missing `@`.

Grammar reference:
https://doc.rust-lang.org/cargo/reference/pkgid-spec.html#package-id-specifications-1
aatran14

This comment was marked as off-topic.

@Shnatsel
Copy link
Copy Markdown
Member

Thanks for the PR! Could you provide a command to reproduce the panic?

return Ok(reader.data());
}
Payload::CustomSection(reader) if reader.name() == ".dep-v0" => {
return Ok(reader.data());
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

unrelated to this PR, but clippy was failing in CI

@pushrax
Copy link
Copy Markdown
Author

pushrax commented May 12, 2026

Could you provide a command to reproduce the panic?

Here's an example repro:

# Cargo.toml
[package]
name = "demo"
version = "0.1.0"
edition = "2021"

[dependencies]
rayon = { git = "https://github.com/rayon-rs/rayon" }

# add trivial main.rs
$ cargo +nightly auditable build --release       # CARGO_BUILD_SBOM not set: works
$ CARGO_BUILD_SBOM=true cargo +nightly auditable build --release -Z sbom
27.70 thread 'main' panicked at cargo-auditable/src/sbom_precursor.rs:195:18:
27.70 Package ID to have a name and version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants