Skip to content

fix(publish): retry provenance signing on Sigstore tlog 409 conflict - #1422

Merged
ghiscoding merged 3 commits into
mainfrom
bugfix/oidc-sigstore-retry
Oct 16, 2026
Merged

ghiscoding merged 3 commits into
mainfrom
bugfix/oidc-sigstore-retry

Conversation

@ghiscoding

@ghiscoding ghiscoding commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Description

Wraps the libnpmpublish publish() call in npmPublish() with a small retry loop that only fires when Sigstore fails with TLOG_CREATE_ENTRY_ERROR and a 409 status ("an equivalent entry already exists in the transparency log").

  • Up to 3 attempts, waiting 2s and then 4s between them
  • A warning is logged on each retry, e.g. Sigstore transparency log conflict (409) for @scope/pkg, retrying provenance signing (attempt 2/3)
  • Any other error (auth, E403, network, etc.) is thrown right away without retrying
  • Also reverts the CI bash retry loop in release.yml (f385d93) so the next releases test the in-library fix directly.

Fix and tests written with help from GitHub Copilot (Claude Opus 5.5)

Motivation and Context

When publishing with provenance (OIDC trusted publishing / short-lived token), the publish sometimes fails partway through with:

lerna-lite ERR! TLOG_CREATE_ENTRY_ERROR error creating tlog entry - (409) an equivalent entry already exists in the transparency log with UUID ...

Root cause: @sigstore/sign retries its own HTTP requests. When the first POST to Rekor actually succeeds but the response is lost (timeout/5xx), the internal retry re-POSTs the same entry and gets a 409. Sigstore has a fetchOnConflict option for this case, but it is hard-coded to false in [email protected] and isn't passed through by libnpmpublish, so we can't turn it on from outside.

Retrying at the Lerna-Lite level is safe because libnpmpublish signs the provenance (buildMetadata) before it uploads the package to the registry. So nothing has been published for that package when this error is thrown. A new attempt signs with a new temporary key, which produces a different signature, so it no longer conflicts.

Until now this had to be worked around in CI with a bash retry loop around lerna publish (see f385d93). With this change, users no longer need their own retry loop in CI.

How Has This Been Tested?

Added unit tests in packages/publish/src/__tests__/npm-publish.spec.ts (using Vitest fake timers):

  • retries and then succeeds after a tlog 409 conflict (publish called twice, postpublish lifecycle still runs)
  • throws the original error after the 3rd failed attempt
  • does not retry on other errors (e.g. E403)

Ran vitest run packages/publish/src/__tests__/npm-publish.spec.ts (20/20 passing), plus oxlint and oxfmt --check on the changed files.

Types of changes

  • Chore (change that has absolutely no effect on users)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@pkg-pr-new

pkg-pr-new Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
@lerna-lite/changed

npm i https://pkg.pr.new/@lerna-lite/changed@1422

@lerna-lite/cli

npm i https://pkg.pr.new/@lerna-lite/cli@1422

@lerna-lite/core

npm i https://pkg.pr.new/@lerna-lite/core@1422

@lerna-lite/diff

npm i https://pkg.pr.new/@lerna-lite/diff@1422

@lerna-lite/exec

npm i https://pkg.pr.new/@lerna-lite/exec@1422

@lerna-lite/init

npm i https://pkg.pr.new/@lerna-lite/init@1422

@lerna-lite/list

npm i https://pkg.pr.new/@lerna-lite/list@1422

@lerna-lite/listable

npm i https://pkg.pr.new/@lerna-lite/listable@1422

@lerna-lite/npmlog

npm i https://pkg.pr.new/@lerna-lite/npmlog@1422

@lerna-lite/profiler

npm i https://pkg.pr.new/@lerna-lite/profiler@1422

@lerna-lite/publish

npm i https://pkg.pr.new/@lerna-lite/publish@1422

@lerna-lite/run

npm i https://pkg.pr.new/@lerna-lite/run@1422

@lerna-lite/version

npm i https://pkg.pr.new/@lerna-lite/version@1422

@lerna-lite/watch

npm i https://pkg.pr.new/@lerna-lite/watch@1422

commit: b05d509

@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (f385d93) to head (b05d509).
⚠️ Report is 9 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##              main     #1422    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files          168       169     +1     
  Lines         5961      6080   +119     
  Branches      1544      1584    +40     
==========================================
+ Hits          5961      6080   +119     

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ghiscoding
ghiscoding merged commit 5fe200d into main Oct 16, 2026
12 checks passed
@ghiscoding
ghiscoding deleted the bugfix/oidc-sigstore-retry branch October 16, 2026 18:22
@github-actions

Copy link
Copy Markdown

🎉 This pull request is included in version 5.6.4 📦
🔗 The release notes are available at: GitHub Release 🚀

commented by latest Lerna-Lite release workflow 🤖

Nick-Lucas added a commit to trpc/trpc that referenced this pull request Oct 28, 2026
## Summary

This bumps `@lerna-lite/cli` and `@lerna-lite/publish` from `^5.6.3` to
`^5.6.4` in the catalog. It also deletes
`patches/@[email protected]`, because 5.6.4 ships the same
change upstream.

5.6.4 includes two release-relevant fixes:

- [lerna-lite#1433](lerna-lite/lerna-lite#1433)
upstreams our 403 PUT response-body logger, with output truncated at
4,000 characters. The upstream PR names #7669 as its origin.
- [lerna-lite#1422](lerna-lite/lerna-lite#1422)
retries provenance signing, up to 3 times, when Sigstore returns
`TLOG_CREATE_ENTRY_ERROR` with a 409. That error ended the second
attempt of the 2026-10-28 canary run
([40729427954](https://github.com/trpc/trpc/actions/runs/40729427954)).

The orphaned `@lerna-lite/{cli,core,init,version}@5.6.3` entries were a
self-referencing cycle that pnpm did not prune, so I removed them from
the lockfile by hand. `pnpm install --frozen-lockfile` and `pnpm install
--lockfile-only` both leave the lockfile unchanged.

## Verification

- `pnpm lerna publish --force-publish --canary --preid canary --dist-tag
canary --yes --dry-run` on lerna-lite 5.6.4 prints `lerna-lite success
published 7 packages [dry-run]`.
- In the installed 5.6.4, `dist/command.js` contains
`logForbiddenPutBody`, and `dist/lib/npm-publish.js` contains
`isTlogConflictError`.

Stacked below #7736.

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Chores**
  * Updated the Lerna Lite CLI and publish tooling to version 5.6.4.

* **Changes**
* Certain failed publish requests no longer include raw response data in
error logs. This reduces diagnostic detail in those cases.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Charon <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

1 participant