action-gh-release icon indicating copy to clipboard operation
action-gh-release copied to clipboard

Getting 422 "already_exists" error on 2.2.2

Open Bertg opened this issue 7 months ago • 6 comments

After upgrading we get this error in our output.

Run softprops/[email protected]
  with:
    target_commitish: c75edc7a731e637485d4a6bb7f707e7ba95f38e3
    tag_name: [email protected]
    append_body: true
    body: [...]
    token: ***
  env:
    COMMITS: [...]
👩‍🏭 Creating new GitHub release for tag [email protected] using commit "c75edc7a731e637485d4a6bb7f707e7ba95f38e3"...
⚠️ GitHub release failed with status: 422
{"message":"Validation Failed","errors":[{"resource":"Release","code":"already_exists","field":"tag_name"}],"documentation_url":"https://docs.github.com/rest/releases/releases#create-a-release","status":"422"}
Skip retry - validation failed
⚠️ Unexpected error fetching GitHub release for tag refs/heads/main: HttpError: Validation Failed: {"resource":"Release","code":"already_exists","field":"tag_name"} - https://docs.github.com/rest/releases/releases#create-a-release
Error: Validation Failed: {"resource":"Release","code":"already_exists","field":"tag_name"} - https://docs.github.com/rest/releases/releases#create-a-release

This is the action:

  publish_release:
    name: ✨ Publish Release
    runs-on: ubuntu-latest
    steps:
      - [...]
      - name: ✨ Publish Release
        uses: softprops/[email protected]
        with:
          target_commitish: ${{ inputs.sha }}
          tag_name: ${{ inputs.name }}
          body: |-
            ## Changes made in Release ${{ inputs.name }}
      - [...]

Any idea what is going on?

Bertg avatar Apr 29 '25 13:04 Bertg

same

renchuwork avatar Apr 29 '25 20:04 renchuwork

same

hronro avatar Apr 30 '25 08:04 hronro

Duplicate of #613?

RadxaYuntian avatar Apr 30 '25 09:04 RadxaYuntian

@RadxaYuntian not duplicate, me fails on uploading release assets either.

hronro avatar May 01 '25 06:05 hronro

I am having same issue!!!!

ELY3M avatar May 14 '25 02:05 ELY3M

I have to change my actions to use this version 2.2.1

- name: Upload Release
  uses: softprops/[email protected]
  with:
    draft: false
    prerelease: false    
    tag_name: ${{ github.run_number }}
    body: ${{ github.event.head_commit.message }}
    files: ${{ github.workspace }}\filename.dll
  env:
    GITHUB_TOKEN: ${{ github.token }} 

then my actions is working again.

ELY3M avatar May 14 '25 02:05 ELY3M

2.3.2 has the same issue. Last working version is 2.2.1

Image

CramBL avatar Jun 26 '25 08:06 CramBL

Did everyone use matrix to create releases in parallel? I suspect it's a concurrency issue.

WhaleFell avatar Aug 01 '25 17:08 WhaleFell

Did everyone use matrix to create releases in parallel? I suspect it's a concurrency issue.

Yes, it's definitely a concurrency issue

CramBL avatar Aug 01 '25 19:08 CramBL

yeah we use matrix because we need to build for different architectures...

sruehl avatar Aug 04 '25 06:08 sruehl

@chenrui333 any idea how to mitigate. Maybe with a retry?

sruehl avatar Aug 04 '25 06:08 sruehl

@sruehl we have worked around this issue with a two-step process.

First step (not matrixed) is publishing a draft: true release and second step is to use the matrix strategy with draft: false so there will always be a release for the second steps and we avoid the race condition.

Image

jlumsden-mts avatar Aug 04 '25 07:08 jlumsden-mts

We just ran into this for the first time as well with 2 workflows running in parallel, one using 2.2.1 and the other 2.0.0. I'm guessing it's just a race condition. One of the 2 should try to update the release, but they don't because when they check if it exists neither has created it yet.

Perhaps the workflow simply shouldn't skip retrying on 422's?

myieye avatar Aug 08 '25 07:08 myieye

I changed my workflow to create a draft first, then it's not an issue when the race condition occurs, as a workaround

patrickleet avatar Aug 16 '25 17:08 patrickleet

http422-retry-count: 2 can it not just wait 20 seconds and retry, only when HTTP/422, upto the limit specified. A value of 2 such as this example would try a total of 3 times with approx 60 seconds of total waiting until a fatal error is given as now.

http422-retry-count: 0 means never and is the default.

Trying to make this easier to understand (untested):

      - name: Release
        id: release1
        uses: softprops/action-gh-release@v2
        with:
          body_path: RELEASE-NOTES.txt
          files: myfile.exe

      - name: wait1
        if: failure()
        shell: bash
        run: sleep 20

      - name: Release 2
        id: release2
        if: steps.release1.outcome != 'success'
        uses: softprops/action-gh-release@v2
        with:
          body_path: RELEASE-NOTES.txt
          files: myfile.exe

      - name: wait2
        if: failure()
        shell: bash
        run: sleep 20

      - name: Release 3
        id: release3
        if: steps.release1.outcome != 'success' && steps.release2.outcome != 'success'
        uses: softprops/action-gh-release@v2
        with:
          body_path: RELEASE-NOTES.txt
          files: myfile.exe

dlmiles avatar Sep 06 '25 16:09 dlmiles

released @stephenway's fix in v2.3.4

chenrui333 avatar Oct 03 '25 18:10 chenrui333