Skip to content

fix: handle upload already_exists races across workflows#745

Merged
chenrui333 merged 2 commits intosoftprops:masterfrom
api2062:api2062/740
Mar 15, 2026
Merged

fix: handle upload already_exists races across workflows#745
chenrui333 merged 2 commits intosoftprops:masterfrom
api2062:api2062/740

Conversation

@api2062
Copy link
Copy Markdown
Contributor

@api2062 api2062 commented Mar 15, 2026

Description

Fixes a race condition when multiple workflows upload an asset with the same filename to the same release tag.

When overwrite_files is enabled (default), concurrent runs can still hit:

Validation Failed: {"resource":"ReleaseAsset","code":"already_exists","field":"name"}

because another workflow may upload between the initial asset check and upload call.

What changed

  • In upload():
    • If upload fails with 422 + already_exists, the action now:
      1. refreshes the release asset list,
      2. finds the conflicting asset by aligned name,
      3. deletes it,
      4. retries the upload once.
  • Added a regression test covering this path:
    • retries upload after deleting conflicting asset on 422 already_exists race.

Fixes #740

Validation

  • npx vitest run __tests__/github.test.ts
  • npm run typecheck
  • npm run build

@api2062 api2062 marked this pull request as ready for review March 15, 2026 00:23
@chenrui333 chenrui333 added the bug Something isn't working label Mar 15, 2026
@chenrui333 chenrui333 changed the title Handle upload already_exists races across workflows fix: handle upload already_exists races across workflows Mar 15, 2026
Aditya Inamdar and others added 2 commits March 14, 2026 21:24
@chenrui333 chenrui333 merged commit 5284765 into softprops:master Mar 15, 2026
1 check passed
@chenrui333
Copy link
Copy Markdown
Collaborator

Thanks @api2062!

@chenrui333
Copy link
Copy Markdown
Collaborator

#767

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When different workflow upload file with the same filename to the same tag, the new file cannot overwrite the old one

2 participants