Conversation
When a published version contained a `+<build>` segment (e.g. `1.0.0-canary.0+abc1234`), `pnpm publish --provenance` was rejected by the registry with a 422 verifying the sigstore provenance bundle. `libnpmpublish.publish()` runs `semver.clean()` on `manifest.version`, which strips build metadata, before computing the provenance subject. pnpm was packing the tarball with the original version, so the version embedded in the packed `package.json` no longer matched the version in the metadata payload and the bundle's subject — causing the registry to reject the publish. Strip build metadata from the published version after creating the publish manifest, then derive both the tarball filename and the manifest packed inside the tarball from that cleaned version. Closes #11518.
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe pull request fixes ChangesBuild Metadata Normalization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
This PR fixes pnpm publish --provenance failures when the package version contains SemVer build metadata (+...) by ensuring the packed tarball and packed package.json use the same normalized version that libnpmpublish uses when computing provenance-related metadata.
Changes:
- Strip SemVer build metadata (
+<build>) from the publish manifest version during packing and use the stripped version for tarball naming /--out %vexpansion. - Add a unit test asserting both the tarball filename and the packed
package.jsonversion exclude build metadata. - Add a changeset bump documenting the fix.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| releasing/commands/src/publish/pack.ts | Normalizes the packed/published version by stripping build metadata and uses it consistently for tarball naming and packed manifest contents. |
| releasing/commands/test/publish/pack.ts | Adds coverage to confirm build metadata is removed from the tarball filename and packed package.json. |
| .changeset/publish-strip-build-metadata.md | Documents the patch-level fix for provenance publishing with build metadata versions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
When a published version contained a `+<build>` segment (e.g. `1.0.0-canary.0+abc1234`), `pnpm publish --provenance` was rejected by the registry with a 422 verifying the sigstore provenance bundle. `libnpmpublish.publish()` runs `semver.clean()` on `manifest.version`, which strips build metadata, before computing the provenance subject. pnpm was packing the tarball with the original version, so the version embedded in the packed `package.json` no longer matched the version in the metadata payload and the bundle's subject — causing the registry to reject the publish. Strip build metadata from the published version after creating the publish manifest, then derive both the tarball filename and the manifest packed inside the tarball from that cleaned version. Closes #11518.
Summary
pnpm publish --provenancewas rejected by the registry with422 Unprocessable Entity — Error verifying sigstore provenance bundle: Failed to validate the provenance subject against the package name, version and tarball integritywhenever the package version contained semver build metadata (e.g.1.0.0-canary.0+abc1234).libnpmpublish.publish()runssemver.clean()onmanifest.versionbefore computing the provenance subject, andsemver.clean()strips the+<build>segment. pnpm was packing the tarball with the original version, so the version embedded in the packedpackage.jsonno longer matched the version in the metadata payload / sigstore subject, and the registry rejected the publish. (npm's CLI dodges this because it normalizes the manifest before packing.)pack.tsaftercreatePublishManifest, then derive both the tarball filename and the packedpackage.jsonfrom the cleaned version, so the tarball, the metadata, and the provenance subject all agree.Test plan
pack: strips semver build metadata from the version) verifies the tarball filename and the packedpackage.jsonuse the cleaned version.releasing/commands/test/publish/pack.tspass.--provenanceis left to a maintainer who can exercise OIDC / a real registry.Written by an agent (Claude Code, claude-opus-4-7).
Summary by CodeRabbit
1.0.0+build). Build metadata is now automatically stripped during publishing to ensure consistent version handling across tarballs and registry submissions.