create-release icon indicating copy to clipboard operation
create-release copied to clipboard

Error reporting could be improved

Open iggy opened this issue 6 years ago • 18 comments

I looked at the code for this action, but I'm not great with the javascript, so not sure I can fix it myself.

When I use this action in one of my workflows and the action receives an error from the github API, it doesn't bubble enough info from the API.

f.ex.

Create Release
Run actions/[email protected]
with:
  tag_name: 7e80c809f34b653a75d675520a69e3295861f68a
  release_name: Release 7e80c809f34b653a75d675520a69e3295861f68a
  draft: false
  prerelease: false
env:
  GOROOT: /opt/hostedtoolcache/go/1.12.10/x64
  GITHUB_TOKEN: ***
##[error]Validation Failed
##[error]Node run failed with exit code 1

From what I can tell the API should be returning an HTTP status code along with a JSON body that has more info like so

422 Validation Failed [{Resource:Release Field:target_commitish Code:invalid Message:}]

It would be nice if the content of that JSON body could somehow be bubbled up to the user in the Actions interface.

iggy avatar Oct 11 '19 22:10 iggy

Hi @iggy,

Thanks for bringing this up! I wanted to respond briefly to let you know I'll be looking into this. I believe there is a way to see additional debug messages in your Action runner, but I need to verify how that works. Once that's done, I can try to add additional debug messaging that would allow you to see the full payload and response. This would be similar to a "log level" where you enable debug logs, then disable them later if you want to reduce the amount of "noise" in the output.

I'll be taking a look this week to see what I can do! 🎉

IAmHughes avatar Oct 13 '19 02:10 IAmHughes

Hey @iggy.

Did some research and I think I found a solution for you. You can turn on additional debugging by adding the following two secrets to your repository's settings:

ACTIONS_RUNNER_DEBUG = true ACTIONS_STEP_DEBUG = true

This will also give you additional logging for things like the payload that triggered the Workflow, which would be in the contextData object as shown below.

"contextData": {
    ...
}

These steps are documented in this repo, and there is some relevant help documentation as well.

Let me know if that helps, and if you have more questions I'll see what I can do to throw additional debugging in. 👍

IAmHughes avatar Oct 14 '19 17:10 IAmHughes

I consider this a serious bug rather than an enhancement request. You always get that Validation Failed error no matter what happened (e.g. release already exists #12). I wasted a lot of time because I thought the token was expired (secrets.GITHUB_TOKEN does that after 1h!).

Trass3r avatar Nov 20 '19 10:11 Trass3r

ACTIONS_RUNNER_DEBUG = true ACTIONS_STEP_DEBUG = true

Even with that I don't see any useful output: https://github.com/Trass3r/testgithubactionsrelease/runs/311483971

Trass3r avatar Nov 20 '19 10:11 Trass3r

Any progress on this issue, its really unclear why this is failing

      - uses: actions/create-release@v1

        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

        with:
          tag_name: ${{ github.sha }}
          release_name: Release ${{ github.sha }}
          draft: false
          prerelease: false

jakelacey2012 avatar Dec 21 '19 10:12 jakelacey2012

@jakelacey2012 I had the same issue, you can't have the tag name as same as a commit

Cubxity avatar Jan 02 '20 16:01 Cubxity

Run actions/[email protected]
  with:
    tag_name: refs/tags/ignore-0.12.16-3
    release_name: Release refs/tags/ignore-0.12.16-3
    body: All notable changes to this version has been documented in the CHANGELOG.md file.
  
    draft: true
    prerelease: false
  env:
    BOX_VERSION: 3.8.4
    GITHUB_TOKEN: ***
##[error]Not Found
##[error]Node run failed with exit code 1

I have no idea what means "Not Found". And I'm pretty sure the tag is exists. I can even use something like cat ".git/${{ github.ref }}" in the same workflow and I can see the SHA.

sergeyklay avatar Jan 15 '20 10:01 sergeyklay

@IAmHughes Is this output tell me something useful?

##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'ref'
##[debug]..=> 'refs/tags/ignore-0.12.16-4'
##[debug]=> 'Release refs/tags/ignore-0.12.16-4'
##[debug]Result: 'Release refs/tags/ignore-0.12.16-4'
##[debug]Loading env
##[debug]Evaluating: secrets.GH_TOKEN
##[debug]Evaluating Index:
##[debug]..Evaluating secrets:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'GH_TOKEN'
##[debug]=> '***'
##[debug]Result: '***'

sergeyklay avatar Jan 15 '20 11:01 sergeyklay

In my case the issue was related due to wrong token ussage (I created yet one in the secrets). You don't need to create your own token.

sergeyklay avatar Jan 15 '20 11:01 sergeyklay

I got the following

Run actions/[email protected]
##[error]Not Found
##[error]Node run failed with exit code 1

Could solve it with a different token with more access rights.

Could you please document what kind of permissions the token needs and improve the error message so others don't run into the same problem.

sebastianfeldmann avatar Jan 18 '20 12:01 sebastianfeldmann

Maybe you're creating a duplicated name's release. I Change name to timestamp and works fine.

rosuH avatar Mar 06 '20 03:03 rosuH

@Cubxity Why can't you have a tag name the same as a commit? For CI/CD, you need a unique tag name to grab the assets for deployment on the other end, yet you can't necessarily use semantic versioning all the time if you're doing CI/CD in a dev environment multiple times a day. What unique identifier can you use the GitHub event?

szul avatar Mar 27 '20 20:03 szul

Received an answer from a GitHub employee on Twitter: You can use the GITHUB_RUN_ID variable for a unique identifier for non-semvar tags/releases.

szul avatar Mar 29 '20 16:03 szul

(with ACTIONS_STEP_DEBUG = true set and) With this step

      - name: Create Release
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.sha }}
          release_name: Release ${{ github.sha }}
          draft: false
          prerelease: false

I was getting

##[group]Run actions/create-release@v1
with:
  tag_name: 46e825c34438558d9789da3d067cf4ff45cd18f5
  release_name: Release 46e825c34438558d9789da3d067cf4ff45cd18f5
  draft: false
  prerelease: false
env:
  GITHUB_TOKEN: ***
##[endgroup]
##[error]Validation Failed
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: Create Release

Thanks to @Cubxity I fixed it by prefixing my release ID with binaries-:

      - name: Create Release
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: binaries-${{ github.sha }}
          release_name: Release ${{ github.sha }}
          draft: false
          prerelease: false

kousu avatar Apr 14 '20 17:04 kousu

I tried @szul's research but it failed; maybe I misunderstood?

      - name: Create Release
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ env.GITHUB_RUN_ID }}
          release_name: Release ${{ github.sha }}
          draft: false
          prerelease: false
##[group]Run actions/create-release@v1
with:
  release_name: Release 7c41ed45657eeaa16cb77adf35e219a4cf696291
  draft: false
  prerelease: false
env:
  GITHUB_TOKEN: ***
##[endgroup]
##[error]Input required and not supplied: tag_name
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: Create Release

If you are using git tags, and only running this on master, and moreover only merging to master on new tags, then then this glitch would never show up, since there would only ever be one run per tag. It seems really easy to to trip over, having a better error message with the details would really help.

kousu avatar Apr 14 '20 17:04 kousu

@kousu Had to output it this way:

- name: Create Release
   id: create_release
   uses: actions/create-release@latest
   env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
   with:
     tag_name: dev-lms-${{ github.run_id }}
     release_name: Release dev-lms-${{ github.run_id }}
     draft: false
     prerelease: false

szul avatar Apr 14 '20 18:04 szul

Amazing, thanks :)

kousu avatar Apr 14 '20 18:04 kousu

@sondreb's work from #29, https://github.com/sondreb/action-release, seems much more like what I want: I want to have an auto-generated draft release, always updated with the latest build, and then I want to manually switch it to published when I am satisfied at which point it should be frozen.

kousu avatar Apr 14 '20 18:04 kousu