Skip to content

fix: add User-Agent header and strict HTTP status check for crates.io version lookup#40

Merged
tehw0lf merged 1 commit intomainfrom
fix/crates-io-version-check
Mar 12, 2026
Merged

fix: add User-Agent header and strict HTTP status check for crates.io version lookup#40
tehw0lf merged 1 commit intomainfrom
fix/crates-io-version-check

Conversation

@tehw0lf
Copy link
Owner

@tehw0lf tehw0lf commented Mar 12, 2026

Summary

  • crates.io API requires a User-Agent header — without it, the API returns 403 instead of 200/404
  • The missing header caused the 403 to fall into the else branch, always setting already_published=false
  • The publish step would therefore always run, even for already-published versions

Changes

  • Added -H "User-Agent: github-actions/publish-crates-io" to the curl request
  • Explicit 404 check for "not yet published" instead of a catch-all else
  • Any unexpected HTTP status (e.g. 403, 500) now fails the job with a clear error message

Test plan

  • Manually tested against crates.io API for wlgen-rs versions:
    • 0.2.1200 (already published) ✅
    • 0.2.2200 (already published) ✅
    • 0.2.3404 (not yet published) ✅

… version lookup

crates.io API requires a User-Agent header and returns 403 without one.
The missing header caused the version check to always evaluate to
already_published=false (403 fell into the else branch), so the
publish step would always run even for already-published versions.

Now only HTTP 200 maps to already_published=true, only 404 maps to
already_published=false, and any other status code fails the job
to prevent silent misbehavior.
@tehw0lf tehw0lf merged commit 2c3c09b into main Mar 12, 2026
2 checks passed
@tehw0lf tehw0lf deleted the fix/crates-io-version-check branch March 12, 2026 22:35
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