Skip to content

fix(publish): retry the sigstore signing exchange and cap it with fetch-timeout - #13245

Merged
zkochan merged 5 commits into
mainfrom
fix-provenance-sign-retry
Jul 23, 2026
Merged

zkochan merged 5 commits into
mainfrom
fix-provenance-sign-retry

Conversation

@zkochan

@zkochan zkochan commented Jul 23, 2026 •

Copy link
Copy Markdown
Member

Summary

The v11.17.0 release run (job 89266951584) failed with ERR_PNPM_PROVENANCE_SIGN while publishing @pnpm/resolving.parse-wanted-dependency: a single request to the sigstore timestamp authority (https://timestamp.sigstore.dev/api/v1/timestamp) errored, and the whole publish aborted — after eight packages had already signed and published fine.

The TypeScript CLI is not affected because it signs through sigstore-js, which runs every Fulcio / TSA / Rekor request under make-fetch-happen with its default retry policy (2 retries, factor 2, 1 s floor) and under the caller's timeout option — which pnpm wires to fetch-timeout (default 60 s), with sigstore-js's own 5 s default as the fallback. pacquet called sigstore_sign's sign_raw_statement exactly once, with no retry and no request timeout (the sigstore-rust clients build bare reqwest::Clients), so any transient sigstore network error killed the release, and a stalled connection hung until the OS dropped the socket (~78 s in the failed run).

This PR closes both gaps:

  • Retry: the production SignProvenance impl retries the signing exchange with sigstore-js's policy. The sigstore_sign crate issues each HTTP request once and exposes no per-request retry hook, so the retry wraps the boundary pacquet owns: the whole signing exchange. Every step of that exchange is idempotent (a fresh ephemeral key, certificate, timestamp, and transparency-log entry per attempt), so re-running it is safe.
  • Timeout: generate_provenance forwards fetch-timeout to the signer, and each signing attempt runs under that deadline (5 s fallback when unset, matching sigstore-js's DEFAULT_TIMEOUT). An elapsed deadline becomes a retryable signing error, so the retry loop picks it up instead of the publish hanging.

Placing both below the DI seam mirrors where sigstore-js keeps them on the TypeScript side and leaves the generate_provenance contract and its test fakes unchanged (the fakes only gained the pass-through timeout parameter).

The retry loop reuses pacquet_network::RetryOpts for the backoff math (the retry module's docs already bless purpose-specific loops that reuse RetryOpts, e.g. the tarball fetcher); retry_async itself was not reused because its warn log line is specific to body-read failures and would mislead someone debugging a release. Retry warnings go through tracing only, not the RequestRetry reporter event, because the TypeScript CLI's sigstore retries are likewise invisible in the reporter stream — emitting the event here would diverge the two stacks' output.

Squash Commit Body

The v11.17.0 release run aborted with ERR_PNPM_PROVENANCE_SIGN after a
single dropped request to the sigstore timestamp authority, even though
the eight packages published before it signed fine.

The TypeScript CLI signs through sigstore-js, which runs every Fulcio /
TSA / Rekor request under make-fetch-happen with its default retry
policy (2 retries, factor 2, 1 s floor) and under the caller's timeout
option, which pnpm wires to fetch-timeout (default 60 s, sigstore-js
falls back to 5 s when unset). pacquet called sign_raw_statement exactly
once with no retry and no request timeout (the sigstore-rust clients
build bare reqwest clients), turning any single network flake into a
failed release and letting a stalled connection hang until the OS
dropped the socket.

Retry the whole signing exchange in the Host SignProvenance impl with
the same policy, and cap each attempt with fetch-timeout (5 s fallback),
converting an elapsed deadline into a retryable signing error. The
exchange is idempotent (fresh ephemeral key, certificate, timestamp,
and transparency-log entry per attempt), so re-running it is safe. Both
sit below the DI seam, matching where sigstore-js keeps them on the
TypeScript side, so the generate_provenance contract is unchanged apart
from the pass-through timeout parameter.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting. (Rust-only:
    the TypeScript CLI already retries and applies fetch-timeout via
    sigstore-js; this brings pacquet to parity.)
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.

Written by an agent (Claude Code, claude-fable-5).

Summary by CodeRabbit

  • New Features

    • Provenance signing now honors the configured fetch timeout.
    • Transient signing failures are automatically retried up to two additional times with exponential backoff.
    • Stalled signing requests now time out instead of hanging indefinitely.
  • Documentation

    • Updated patch release notes to document the improved provenance-signing behavior.

zkochan and others added 2 commits July 23, 2026 18:42
The v11.17.0 release run aborted with ERR_PNPM_PROVENANCE_SIGN after a
single dropped request to the sigstore timestamp authority
(https://timestamp.sigstore.dev/api/v1/timestamp), even though the eight
packages published before it signed fine.

The TypeScript CLI signs through sigstore-js, which wraps every Fulcio /
TSA / Rekor request in make-fetch-happen with its default retry policy
(2 retries, factor 2, 1 s floor), so a transient sigstore hiccup never
aborts a publish there. pacquet called sign_raw_statement exactly once,
turning any single network flake into a failed release.

Retry the whole signing exchange in the Host SignProvenance impl with
the same policy. The exchange is idempotent (fresh ephemeral key,
certificate, timestamp, and transparency-log entry per attempt), so
re-running it is safe. The retry sits below the DI seam, matching where
sigstore-js keeps it on the TypeScript side, so the generate_provenance
contract and its fakes are unchanged.

Co-Authored-By: Claude Fable 5 <[email protected]>
Copilot AI review requested due to automatic review settings July 23, 2026 16:46

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The publish crate now applies fetch-timeout to each sigstore provenance signing attempt, retries failures and timeouts with exponential backoff, logs intermediate failures, and returns the final error after exhausting retries. Tests cover deadlines, recovery, and exhaustion.

Changes

Provenance signing retries

Layer / File(s) Summary
Timeout-aware signing contract
pnpm/crates/publish/Cargo.toml, pnpm/crates/publish/src/provenance_gen.rs
Provenance generation passes fetch-timeout through the updated signing interface, with Tokio time and tracing dependencies added.
Signing retry implementation
pnpm/crates/publish/src/provenance_gen.rs
Production sigstore signing wraps each attempt in a timeout, retries failures with exponential backoff, logs intermediate errors, and propagates the final error.
Retry validation and release metadata
pnpm/crates/publish/src/provenance_gen/tests.rs, pnpm/crates/publish/src/publish_packed_pkg/tests.rs, .changeset/retry-provenance-signing.md
Tests verify timeout handling, transient recovery, exhausted retries, and updated signer contracts; the changeset documents the behavior.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested labels: product: pacquet

Suggested reviewers: copilot

Sequence Diagram(s)

sequenceDiagram
  participant ProvenanceGeneration
  participant sign_with_retry
  participant SigningContext
  ProvenanceGeneration->>sign_with_retry: sign statement with fetch-timeout
  sign_with_retry->>SigningContext: signing attempt
  SigningContext-->>sign_with_retry: success or failure
  sign_with_retry->>sign_with_retry: timeout, warn, and exponential backoff
  sign_with_retry-->>ProvenanceGeneration: signed bundle or final error
Loading
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-provenance-sign-retry

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qodo-code-review

qodo-code-review Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Retry sigstore provenance signing on transient publish failures

🐞 Bug fix 🧪 Tests ⚙️ Configuration changes 📝 Documentation 🕐 20-40 Minutes

Grey Divider

AI Description

• Add exponential-backoff retries around the full sigstore signing exchange during publish.
• Log retry attempts and delay to make transient sigstore outages diagnosable.
• Add unit tests covering retry recovery and exhaustion behavior.
Diagram

graph TD
A["pnpm publish"] --> B["pacquet publish"] --> C["generate_provenance"] --> D["Host SignProvenance"] --> E{"sign_with_retry"} --> F["sigstore_sign exchange"] --> G{{"Sigstore infra"}}
E -- "on transient error" --> H["tokio sleep/backoff"] --> E
subgraph Legend
  direction LR
  _proc["Component"] ~~~ _dec{"Retry decision"} ~~~ _ext{{"External service"}}
end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Add per-request retry inside sigstore_sign (upstream)
  • ➕ Retries are closer to the failing HTTP calls (more targeted, less total work per retry).
  • ➕ Would benefit all sigstore_sign consumers automatically.
  • ➖ Not currently supported by the crate; larger scope and release coordination required.
  • ➖ Harder to ship quickly as a reliability fix for pnpm’s release pipeline.
2. Wrap sigstore_sign’s HTTP client with middleware (reqwest/hyper retry)
  • ➕ Retries only network calls, not the entire signing exchange.
  • ➕ Could preserve a single logical signing attempt while improving resiliency.
  • ➖ Depends on sigstore_sign exposing a client hook/configuration; may be infeasible.
  • ➖ More complex to ensure safe retry semantics across different request types.
3. Reuse pacquet_network::retry_async with customizable logging
  • ➕ Centralizes retry behavior in an existing helper and keeps policies consistent.
  • ➕ Less bespoke retry code to maintain long-term.
  • ➖ Current helper’s log message is misleading for signing failures (as noted in the PR).
  • ➖ Would require enhancing the helper API, increasing change surface area.

Recommendation: The chosen approach—retrying the full signing exchange at the pacquet-owned boundary—is the most pragmatic and safest short-term reliability fix given sigstore_sign does not expose per-request retry hooks. It mirrors the TypeScript side’s resiliency goal, keeps the DI seam and fakes unchanged, and is justified by the exchange’s idempotent semantics.

Files changed (5) +115 / -8

Bug fix (1) +62 / -7
provenance_gen.rsRetry sigstore signing exchange with exponential backoff +62/-7

Retry sigstore signing exchange with exponential backoff

• Wraps the production 'SignProvenance' implementation in a new 'sign_with_retry' helper using 'pacquet_network::RetryOpts'. Adds structured warning logs and backoff sleeps between attempts, and factors retry policy into a constant matching the TypeScript CLI behavior.

pnpm/crates/publish/src/provenance_gen.rs

Tests (1) +45 / -1
tests.rsAdd tests for retry recovery and exhaustion in signing +45/-1

Add tests for retry recovery and exhaustion in signing

• Introduces unit tests validating that 'sign_with_retry' succeeds after transient failures and surfaces the final error once retries are exhausted, using a zero-delay retry policy to keep tests fast.

pnpm/crates/publish/src/provenance_gen/tests.rs

Documentation (1) +5 / -0
retry-provenance-signing.mdDocument retry behavior for provenance signing during publish +5/-0

Document retry behavior for provenance signing during publish

• Adds a changeset announcing that 'pnpm publish --provenance' retries the sigstore signing exchange on transient infrastructure failures with exponential backoff.

.changeset/retry-provenance-signing.md

Other (2) +3 / -0
Cargo.lockLockfile update for added publish-crate dependencies +1/-0

Lockfile update for added publish-crate dependencies

• Updates the lockfile to include 'tracing' in the resolved dependency graph after adding it to the publish crate.

Cargo.lock

Cargo.tomlAdd tokio time and tracing dependencies for signing retries +2/-0

Add tokio time and tracing dependencies for signing retries

• Adds 'tokio' with the 'time' feature to support async sleep-based backoff and adds 'tracing' for retry warning logs.

pnpm/crates/publish/Cargo.toml

@greptile-apps

greptile-apps Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains within the scope of the previous review threads.

Reviews (4): Last reviewed commit: "refactor(publish): drop sign-retry doc c..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
lockfile/parse_pnpm_lock       1.00     12.1±0.27ms    30.8 MB/sec    1.91     23.2±0.94ms    16.1 MB/sec
packument/parse                1.00     41.9±0.47µs  1583.5 MB/sec    1.73    72.4±10.27µs   915.7 MB/sec
tarball/download_dependency    1.00      3.7±0.55ms  1156.9 KB/sec    1.48      5.6±1.04ms   780.1 KB/sec

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm/crates/publish/src/provenance_gen.rs`:
- Around line 145-174: The retry warning in sign_with_retry currently logs the
ProvenanceGenError display text without sanitization. Sanitize the rendered
error before passing it to tracing::warn!, reusing an existing redaction helper
such as redact_url_credentials where applicable or adding a provenance-specific
helper that removes embedded secret headers and URL credentials; preserve the
retry behavior and warning context.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 732f1d71-943b-417c-ae50-c5f6a721a8ac

📥 Commits

Reviewing files that changed from the base of the PR and between 6fb1095 and 346f238.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !Cargo.lock
📒 Files selected for processing (4)
  • .changeset/retry-provenance-signing.md
  • pnpm/crates/publish/Cargo.toml
  • pnpm/crates/publish/src/provenance_gen.rs
  • pnpm/crates/publish/src/provenance_gen/tests.rs

Copilot AI review requested due to automatic review settings July 23, 2026 16:56

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 23, 2026
@qodo-code-review

qodo-code-review Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (4) 📘 Rule violations (1) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 24 rules

Grey Divider


Remediation recommended

1. Default signing timeout too low 🐞 Bug ☼ Reliability ⭐ New
Description
When OidcHttpOptions.fetch_timeout is None, Host::sign_statement enforces a 5s
DEFAULT_SIGN_TIMEOUT for the entire sigstore signing exchange, which can be too short for normal
multi-service signing flows in slower CI environments. This turns what would otherwise be a
slow-but-successful signing attempt into deterministic timeouts + retries and can still fail the
publish with ERR_PNPM_PROVENANCE_SIGN.
Code

pnpm/crates/publish/src/provenance_gen.rs[R152-156]

+/// sigstore-js's `DEFAULT_TIMEOUT`, used only when the caller supplies no
+/// `fetch-timeout` — the sigstore-rust clients set no request timeout of
+/// their own, so without a deadline a hung connection stalls the publish
+/// until the OS gives up on the socket.
+const DEFAULT_SIGN_TIMEOUT: Duration = Duration::from_secs(5);
Evidence
The code uses timeout.unwrap_or(DEFAULT_SIGN_TIMEOUT) and defines DEFAULT_SIGN_TIMEOUT as 5
seconds; OidcHttpOptions.fetch_timeout is optional and defaults to None, and pnpm’s general
fetch timeout default is 60s, making the 5s implicit signing deadline notably stricter.

pnpm/crates/publish/src/provenance_gen.rs[121-134]
pnpm/crates/publish/src/provenance_gen.rs[152-176]
pnpm/crates/publish/src/oidc.rs[115-124]
pnpm/crates/config/src/defaults.rs[256-258]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
If no `fetch-timeout` is configured (`OidcHttpOptions.fetch_timeout == None`), provenance signing now uses a hard-coded 5 second deadline for the entire sigstore signing exchange. This is much lower than the general default fetch timeout used elsewhere (60s) and risks causing avoidable failures/retries in slower CI or during sigstore load.

## Issue Context
`deadline = timeout.unwrap_or(DEFAULT_SIGN_TIMEOUT)` and `DEFAULT_SIGN_TIMEOUT` is set to 5 seconds.

## Fix Focus Areas
- pnpm/crates/publish/src/provenance_gen.rs[122-123]
- pnpm/crates/publish/src/provenance_gen.rs[152-176]

## Suggested fixes
- Increase `DEFAULT_SIGN_TIMEOUT` substantially (e.g., align with the default fetch timeout used elsewhere, such as 60s), or
- Avoid a separate hard-coded default and instead require the caller to pass an explicit timeout (e.g., always populate `OidcHttpOptions.fetch_timeout` at the API boundary).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Fetch-timeout semantic mismatch 🐞 Bug ➹ Performance ⭐ New
Description
generate_provenance forwards fetch_timeout into Host::sign_statement, where it is enforced as
a deadline around the entire sigstore signing exchange; this makes the user-facing fetch-timeout
behave like a whole-attempt budget rather than the per-request deadline it represents elsewhere.
Users who tune fetch-timeout for registry/tarball requests can now unintentionally force
provenance signing to time out and retry/fail under normal-but-slow sigstore exchanges.
Code

pnpm/crates/publish/src/provenance_gen.rs[R77-78]

+    let timeout = options.fetch_timeout.map(Duration::from_millis);
+    let signed = Sys::sign_statement(&jwt, &statement_bytes, timeout).await?;
Evidence
The PR passes OidcHttpOptions.fetch_timeout into the signer and then uses it as the
tokio::time::timeout deadline around the full sign_raw_statement exchange, while the network
module documents fetch_timeout as a per-request deadline used broadly across the codebase.

pnpm/crates/publish/src/provenance_gen.rs[54-79]
pnpm/crates/publish/src/provenance_gen.rs[113-134]
pnpm/crates/publish/src/provenance_gen.rs[158-176]
pnpm/crates/network/src/lib.rs[288-294]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`fetch-timeout` is used broadly as a per-request deadline, but the new provenance signing path applies it as a timeout for the *entire* sigstore signing attempt (a multi-request exchange). This semantic mismatch can lead to unexpected timeouts/retries when users configure `fetch-timeout` based on single-request operations.

## Issue Context
The signing attempt is wrapped by `tokio::time::timeout(deadline, attempt)` where `deadline` is derived from `OidcHttpOptions.fetch_timeout`.

## Fix Focus Areas
- pnpm/crates/publish/src/provenance_gen.rs[74-78]
- pnpm/crates/publish/src/provenance_gen.rs[122-131]
- pnpm/crates/publish/src/provenance_gen.rs[158-176]

## Suggested fixes
- Option A (preferred): introduce a separate, explicitly-scoped timeout knob for provenance signing (e.g., `provenance_sign_timeout_ms`) and map `fetch-timeout` to it only as a default.
- Option B: if keeping `fetch-timeout`, document clearly that it is a per-*signing attempt* budget (not per request) and consider inflating the deadline (e.g., `deadline = fetch_timeout * N`) to better approximate a per-request budget across multiple calls.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Retries non-transient sign errors 🐞 Bug ➹ Performance
Description
sign_with_retry retries every signing failure returned by the signing exchange closure (currently
mapped to ProvenanceGenError::Sign) without distinguishing transient network failures from
deterministic errors. This can add avoidable backoff/extra exchanges (and extra sigstore load) for
permanent failures, unlike the repo’s existing retry helpers which gate retries on specific
retryable conditions.
Code

pnpm/crates/publish/src/provenance_gen.rs[R156-173]

+    loop {
+        match attempt_fn().await {
+            Ok(signed) => return Ok(signed),
+            Err(error) if attempt < retry_opts.retries => {
+                let delay = retry_opts.delay_for(attempt);
+                tracing::warn!(
+                    target: "pacquet_publish::provenance",
+                    error = %redact_url_credentials(&error.to_string()),
+                    attempt = attempt + 1,
+                    max_attempts = retry_opts.retries + 1,
+                    ?delay,
+                    "Signing the provenance statement failed; retrying after backoff",
+                );
+                tokio::time::sleep(delay).await;
+                attempt += 1;
+            }
+            Err(error) => return Err(error),
+        }
Evidence
sign_with_retry retries on any error from the attempt closure until retries are exhausted. The
repo’s network retry helper demonstrates an established pattern of retrying only on specific
retryable statuses/transport errors rather than unconditional retries.

pnpm/crates/publish/src/provenance_gen.rs[155-173]
pnpm/crates/network/src/retry.rs[95-103]
pnpm/crates/network/src/retry.rs[121-171]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The new retry loop retries on any `Err(error)` from the signing attempt while `attempt < retries`, but the PR intent is “retry on transient failures.” Without a predicate/classification, deterministic signing failures (auth/config/validation) will still incur retries + sleeps.

### Issue Context
The codebase’s shared network retry path (`send_with_retry`) is explicit about which failures merit retry (transport errors and a specific status set), which prevents wasting time/requests on permanent failures.

### Fix Focus Areas
- pnpm/crates/publish/src/provenance_gen.rs[156-173]

### Suggested fix
- Introduce a `should_retry_sign_error(&ProvenanceGenError) -> bool` (or pass a predicate into `sign_with_retry`) and only retry when it returns true.
- Prefer preserving structured error information from `sigstore_sign` (instead of immediately converting to `source.to_string()`), so you can reliably detect transient categories (timeouts / connection resets / 408 / 429 / 5xx) and avoid retrying permanent errors.
- If preserving structured errors is too invasive, implement a conservative predicate that retries only when the error text clearly indicates a transient network condition, and otherwise returns immediately.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (2)
4. Changeset missing pnpm bump 📘 Rule violation § Compliance
Description
The new changeset only declares a version bump for pacquet, but does not include the required
pnpm package entry. This can cause release tooling to miss the intended pnpm user-visible
publish behavior change.
Code

.changeset/retry-provenance-signing.md[R1-3]

+---
+"pacquet": patch
+---
Evidence
PR Compliance ID 713436 requires every new/modified changeset to explicitly include a pnpm entry
with a valid bump type. The added changeset front-matter lists only pacquet, omitting pnpm.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/retry-provenance-signing.md[1-3]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new changeset file does not declare a bump for the `pnpm` package, which is required by the compliance checklist.

## Issue Context
This PR changes user-visible `pnpm publish --provenance` behavior, but the changeset front-matter only lists `pacquet`.

## Fix Focus Areas
- .changeset/retry-provenance-signing.md[1-3]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Unsanitized signing error logs 🐞 Bug ⛨ Security
Description
The new retry warning logs error.to_string() using only redact_url_credentials, so control
characters (and any non-URL secrets included in the error text) can still reach CI logs. This
diverges from existing network/CLI patterns that use redact_and_sanitize to prevent terminal/log
injection and credential leakage from URL-bearing text.
Code

pnpm/crates/publish/src/provenance_gen.rs[R161-169]

+                tracing::warn!(
+                    target: "pacquet_publish::provenance",
+                    error = %redact_url_credentials(&error.to_string()),
+                    attempt = attempt + 1,
+                    max_attempts = retry_opts.retries + 1,
+                    ?delay,
+                    "Signing the provenance statement failed; retrying after backoff",
+                );
+                tokio::time::sleep(delay).await;
Evidence
The new warn log uses URL-credential redaction only, while the codebase already documents and uses a
stronger helper (redact_and_sanitize) for safely logging untrusted URL-bearing text (credentials +
control chars).

pnpm/crates/publish/src/provenance_gen.rs[160-170]
pnpm/crates/network/src/auth.rs[745-783]
pnpm/crates/cli/src/cli_args/ping.rs[71-92]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`sign_with_retry` emits a `tracing::warn!` with `error = %redact_url_credentials(&error.to_string())`. This only strips inline `user:pass@` and does not remove control characters, despite the repo already having `redact_and_sanitize` specifically for making untrusted URL-bearing text safe for stderr/CI logs.

### Issue Context
Other network-facing paths (e.g. `pnpm ping`) sanitize and redact error strings before surfacing them. The retry warning is new and will run in CI when sigstore infrastructure flakes.

### Fix Focus Areas
- pnpm/crates/publish/src/provenance_gen.rs[161-169]

### Suggested fix
- Replace `redact_url_credentials(&error.to_string())` with `redact_and_sanitize(&error.to_string())`.
- Update the import to pull `redact_and_sanitize` from `pacquet_network` (and drop `redact_url_credentials` if no longer used).
- (Optional) Consider sanitizing *only* the inner `source` text if you want to preserve the outer error prefix unchanged.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Previous review results

Review updated until commit bab8385

Results up to commit 0b690f3 ⚖️ Balanced


🐞 Bugs (2) 📘 Rule violations (1) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Remediation recommended
1. Changeset missing pnpm bump 📘 Rule violation § Compliance
Description
The new changeset only declares a version bump for pacquet, but does not include the required
pnpm package entry. This can cause release tooling to miss the intended pnpm user-visible
publish behavior change.
Code

.changeset/retry-provenance-signing.md[R1-3]

+---
+"pacquet": patch
+---
Evidence
PR Compliance ID 713436 requires every new/modified changeset to explicitly include a pnpm entry
with a valid bump type. The added changeset front-matter lists only pacquet, omitting pnpm.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/retry-provenance-signing.md[1-3]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new changeset file does not declare a bump for the `pnpm` package, which is required by the compliance checklist.

## Issue Context
This PR changes user-visible `pnpm publish --provenance` behavior, but the changeset front-matter only lists `pacquet`.

## Fix Focus Areas
- .changeset/retry-provenance-signing.md[1-3]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Unsanitized signing error logs 🐞 Bug ⛨ Security
Description
The new retry warning logs error.to_string() using only redact_url_credentials, so control
characters (and any non-URL secrets included in the error text) can still reach CI logs. This
diverges from existing network/CLI patterns that use redact_and_sanitize to prevent terminal/log
injection and credential leakage from URL-bearing text.
Code

pnpm/crates/publish/src/provenance_gen.rs[R161-169]

+                tracing::warn!(
+                    target: "pacquet_publish::provenance",
+                    error = %redact_url_credentials(&error.to_string()),
+                    attempt = attempt + 1,
+                    max_attempts = retry_opts.retries + 1,
+                    ?delay,
+                    "Signing the provenance statement failed; retrying after backoff",
+                );
+                tokio::time::sleep(delay).await;
Evidence
The new warn log uses URL-credential redaction only, while the codebase already documents and uses a
stronger helper (redact_and_sanitize) for safely logging untrusted URL-bearing text (credentials +
control chars).

pnpm/crates/publish/src/provenance_gen.rs[160-170]
pnpm/crates/network/src/auth.rs[745-783]
pnpm/crates/cli/src/cli_args/ping.rs[71-92]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`sign_with_retry` emits a `tracing::warn!` with `error = %redact_url_credentials(&error.to_string())`. This only strips inline `user:pass@` and does not remove control characters, despite the repo already having `redact_and_sanitize` specifically for making untrusted URL-bearing text safe for stderr/CI logs.

### Issue Context
Other network-facing paths (e.g. `pnpm ping`) sanitize and redact error strings before surfacing them. The retry warning is new and will run in CI when sigstore infrastructure flakes.

### Fix Focus Areas
- pnpm/crates/publish/src/provenance_gen.rs[161-169]

### Suggested fix
- Replace `redact_url_credentials(&error.to_string())` with `redact_and_sanitize(&error.to_string())`.
- Update the import to pull `redact_and_sanitize` from `pacquet_network` (and drop `redact_url_credentials` if no longer used).
- (Optional) Consider sanitizing *only* the inner `source` text if you want to preserve the outer error prefix unchanged.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Retries non-transient sign errors 🐞 Bug ➹ Performance
Description
sign_with_retry retries every signing failure returned by the signing exchange closure (currently
mapped to ProvenanceGenError::Sign) without distinguishing transient network failures from
deterministic errors. This can add avoidable backoff/extra exchanges (and extra sigstore load) for
permanent failures, unlike the repo’s existing retry helpers which gate retries on specific
retryable conditions.
Code

pnpm/crates/publish/src/provenance_gen.rs[R156-173]

+    loop {
+        match attempt_fn().await {
+            Ok(signed) => return Ok(signed),
+            Err(error) if attempt < retry_opts.retries => {
+                let delay = retry_opts.delay_for(attempt);
+                tracing::warn!(
+                    target: "pacquet_publish::provenance",
+                    error = %redact_url_credentials(&error.to_string()),
+                    attempt = attempt + 1,
+                    max_attempts = retry_opts.retries + 1,
+                    ?delay,
+                    "Signing the provenance statement failed; retrying after backoff",
+                );
+                tokio::time::sleep(delay).await;
+                attempt += 1;
+            }
+            Err(error) => return Err(error),
+        }
Evidence
sign_with_retry retries on any error from the attempt closure until retries are exhausted. The
repo’s network retry helper demonstrates an established pattern of retrying only on specific
retryable statuses/transport errors rather than unconditional retries.

pnpm/crates/publish/src/provenance_gen.rs[155-173]
pnpm/crates/network/src/retry.rs[95-103]
pnpm/crates/network/src/retry.rs[121-171]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The new retry loop retries on any `Err(error)` from the signing attempt while `attempt < retries`, but the PR intent is “retry on transient failures.” Without a predicate/classification, deterministic signing failures (auth/config/validation) will still incur retries + sleeps.

### Issue Context
The codebase’s shared network retry path (`send_with_retry`) is explicit about which failures merit retry (transport errors and a specific status set), which prevents wasting time/requests on permanent failures.

### Fix Focus Areas
- pnpm/crates/publish/src/provenance_gen.rs[156-173]

### Suggested fix
- Introduce a `should_retry_sign_error(&ProvenanceGenError) -> bool` (or pass a predicate into `sign_with_retry`) and only retry when it returns true.
- Prefer preserving structured error information from `sigstore_sign` (instead of immediately converting to `source.to_string()`), so you can reliably detect transient categories (timeouts / connection resets / 408 / 429 / 5xx) and avoid retrying permanent errors.
- If preserving structured errors is too invasive, implement a conservative predicate that retries only when the error text clearly indicates a transient network condition, and otherwise returns immediately.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

The sigstore-rust clients build their reqwest clients with no request
timeout, so a stalled connection hangs the publish until the OS drops
the socket (~78 s in the failed v11.17.0 release run). sigstore-js
instead runs every request under the caller's timeout option, which
pnpm's TypeScript CLI wires to fetch-timeout (default 60 s), falling
back to sigstore-js's 5 s default when unset.

Mirror that: generate_provenance forwards fetch-timeout to the signer,
and the Host impl caps each signing attempt with it (5 s fallback),
converting an elapsed deadline into a retryable signing error so the
existing retry loop picks it up.

Co-Authored-By: Claude Fable 5 <[email protected]>
Copilot AI review requested due to automatic review settings July 23, 2026 17:06

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@zkochan zkochan changed the title fix(publish): retry the sigstore signing exchange on transient failures fix(publish): retry the sigstore signing exchange and cap it with fetch-timeout Jul 23, 2026
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 44e37b2

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

Copilot AI review requested due to automatic review settings July 23, 2026 17:12

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit bab8385

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@coderabbitai coderabbitai Bot left a comment

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.

🧹 Nitpick comments (1)
pnpm/crates/publish/src/provenance_gen.rs (1)

151-154: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use regular comments only where they add implementation rationale.

  • pnpm/crates/publish/src/provenance_gen.rs#L151-L154: change /// to //; this explains a private implementation decision, not a public API contract.
  • pnpm/crates/publish/src/provenance_gen/tests.rs#L326-L327: remove the comment; the test name already states the behavior.

As per coding guidelines, “Use rustdoc comments for public API contracts and regular comments for implementation rationale” and “Do not duplicate test behavior in documentation.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pnpm/crates/publish/src/provenance_gen.rs` around lines 151 - 154, The
comment near the provenance generation implementation is rationale for private
behavior, so change its rustdoc markers to regular comments in
pnpm/crates/publish/src/provenance_gen.rs lines 151-154. Remove the redundant
behavior-explaining comment in pnpm/crates/publish/src/provenance_gen/tests.rs
lines 326-327; the test name already documents the behavior.

Sources: Coding guidelines, Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@pnpm/crates/publish/src/provenance_gen.rs`:
- Around line 151-154: The comment near the provenance generation implementation
is rationale for private behavior, so change its rustdoc markers to regular
comments in pnpm/crates/publish/src/provenance_gen.rs lines 151-154. Remove the
redundant behavior-explaining comment in
pnpm/crates/publish/src/provenance_gen/tests.rs lines 326-327; the test name
already documents the behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 43ce4bb3-fe75-423d-8a78-ef5636ef1d32

📥 Commits

Reviewing files that changed from the base of the PR and between 346f238 and bab8385.

📒 Files selected for processing (4)
  • .changeset/retry-provenance-signing.md
  • pnpm/crates/publish/src/provenance_gen.rs
  • pnpm/crates/publish/src/provenance_gen/tests.rs
  • pnpm/crates/publish/src/publish_packed_pkg/tests.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/retry-provenance-signing.md

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 65.38462% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.92%. Comparing base (454e7d6) to head (bab8385).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
pnpm/crates/publish/src/provenance_gen.rs 65.38% 18 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13245      +/-   ##
==========================================
- Coverage   86.94%   86.92%   -0.03%     
==========================================
  Files         528      528              
  Lines       90472    90516      +44     
==========================================
+ Hits        78661    78678      +17     
- Misses      11811    11838      +27     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zkochan
zkochan merged commit cb68cb0 into main Jul 23, 2026
33 checks passed
@zkochan
zkochan deleted the fix-provenance-sign-retry branch July 23, 2026 17:24
@qodo-code-review qodo-code-review Bot mentioned this pull request Oct 11, 2026
4 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants