Skip to content

fix: use cargo publish output for idempotency instead of REST API#16

Merged
sopak merged 1 commit into
mainfrom
fix/cargo-publish-idempotency
Jun 25, 2026
Merged

fix: use cargo publish output for idempotency instead of REST API#16
sopak merged 1 commit into
mainfrom
fix/cargo-publish-idempotency

Conversation

@sopak

@sopak sopak commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Problem

crate_version_exists() used crates.io REST API to check if a version was already published, but cargo publish uses the local registry index. These two sources are not synchronized — the REST API can lag behind, causing cargo publish to fail with error: crate ... already exists even though the REST API check passed.

Fix

Replaced REST API pre-check + wait_for_crate loop with a simpler approach:

  • cargo publish is always attempted
  • If it fails with "already exists" in stderr → caught and skipped gracefully
  • If it fails for any other reason → the real error is surfaced
  • Uses the same data source (local registry index) as the actual publish operation — no desynchronization possible

Changes

  • Removed crate_version_exists() and wait_for_crate() bash functions
  • Removed curl and jq dependency from the publish step
  • publish_crate() now captures cargo publish stderr+stdout and inspects output
  • Net: 42 lines removed, 19 added — simpler and more reliable

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@sopak sopak merged commit 147da9f into main Jun 25, 2026
9 checks passed
@sopak sopak deleted the fix/cargo-publish-idempotency branch June 25, 2026 18:11
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