softprops / action-gh-release

📦 :octocat: GitHub Action for creating GitHub Releases
MIT License
4.09k stars 450 forks source link

enhancement: display more helpful error message other than undefined #438

Open networkhermit opened 5 months ago

networkhermit commented 5 months ago

Currently when the action fails it displays undefined as part of the error message, which is not very helpful for debugging.

👩‍🏭 Creating new GitHub release for tag latest...
⚠️ GitHub release failed with status: 403
undefined
retrying... (2 retries remaining)
👩‍🏭 Creating new GitHub release for tag latest...
⚠️ GitHub release failed with status: 403
undefined
retrying... (1 retries remaining)
👩‍🏭 Creating new GitHub release for tag latest...
⚠️ GitHub release failed with status: 403
undefined
retrying... (0 retries remaining)
❌ Too many retries. Aborting...
Error: Too many retries.

I believe the specific line is in https://github.com/softprops/action-gh-release/blob/9b795e578288d5ff64564dfa7dd4cda7b04bb648/src/github.ts#L316

It seems that more helpful error message can be displayed (taken from my scratch fork to troubleshooting a coredns release issue):

          }\n${error}\nretrying... (${
👩‍🏭 Creating new GitHub release for tag v1.11.2 using commit "01bded8194be73ce4601ad608a0464166cee932a"...
⚠️ GitHub release failed with status: 403
HttpError: Resource not accessible by integration
retrying... (2 retries remaining)
👩‍🏭 Creating new GitHub release for tag v1.11.2 using commit "01bded8194be73ce4601ad608a0464166cee932a"...
⚠️ GitHub release failed with status: 403
HttpError: Resource not accessible by integration
retrying... (1 retries remaining)
👩‍🏭 Creating new GitHub release for tag v1.11.2 using commit "01bded8194be73ce4601ad608a0464166cee932a"...
⚠️ GitHub release failed with status: 403
HttpError: Resource not accessible by integration
retrying... (0 retries remaining)
❌ Too many retries. Aborting...
Error: Too many retries.

Related issue showing undefined: #217 #400 #411 #429

I'm not very familiar with typescript and the tooling used, so I hope some existing contributor or volunteer could help improve it.

Even more helpful error message other than plain undefined is appropriated too.

softprops commented 5 months ago

Thanks for capturing this in one gh issue. It's possible this regressed in a version bump. The point of logging the error was to provide helpful debugging when something goes wrong. I agree it's not at all helpful at the moment printing undefined.

I'm hoping to anyone willing to help with this one.

till commented 5 months ago

@softprops just ran into this too, can you try to dump the entire response since errors seems undefined? Or what do you think is required to help?

till commented 5 months ago

It seems like I cannot run this from a branch? Like I need to run some command to regenerate dist? If you can add details as I am also not familiar with TypeScript, then I can try to help.

softprops commented 5 months ago

@till ah yes, if you run npm install to make sure you have dependencies installed then you can run npm build to generate a new packaged distribution file. This is ultimately what github actions uses as an entrypoint for the action

softprops commented 5 months ago

I just merged https://github.com/softprops/action-gh-release/pull/447 could someone on this issue thread try a test release using the current master branch of this action? once we starting seeing data it should start shaking out the underlying issue

till commented 5 months ago

That was supposed to be for testing 😆

softprops commented 5 months ago

no worries. the more info we can gather the sooner we can get the underlying issue addressed

till commented 5 months ago

I figured out my problem: PAT was missing some permissions. In the end used the workflow token again and configured it appropriately.