-
Notifications
You must be signed in to change notification settings - Fork 14
Error responses fail job and provide a bit more output #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| if (response.ok) { | ||
| core.info(`Deploy ${data.status} - Commit: ${data.commit.message}`) | ||
| } else { | ||
| core.setFailed(`Deploy error: ${data.message} (status code ${response.status})`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am seeing an issue here. It seems like it is an issue with the Render API not behaving like the documentation suggests.
Docs show that a 401 error should return the error object like other error responses
However, it seems that a 401 unauthorized never returns JSON. Just the string "Unauthorized". This results in an error I noticed when getting this setup.
Run dylanfm/render-deploy-action@status-fails
undefined:1
Unauthorized
^
SyntaxError: Unexpected token U in JSON at position 0
at JSON.parse (<anonymous>)
at Response.json (/home/runner/work/_actions/dylanfm/render-deploy-action/status-fails/dist/index.js:6968:15)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
If the API docs aren't right for this particular error case, maybe the code needs a special case for 401 responses that doesn't expect JSON.
Comparison to another error using curl shows that at least 404 errors do return JSON (although not the "id" property from docs).
$ curl --request POST --url https://api.render.com/v1/services/serviceId/deploys --header 'Accept: application/json' --header 'Content-Type: application/json' --header 'Authorization: Bearer abc'
Unauthorized
$ curl --request POST --url https://api.render.com/v1/services/serviceId/deploys --header 'Accept: application/json' --header 'Content-Type: application/json' --header 'Authorization: Bearer rnd_aRealKey'
{"message":"not found: service serviceId"}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great spot, I've raised it with our engineering team. It does seem that the Unauthorized one is the only one that returns plain text which isn't as it's documented.
|
@DylanFM mind to fix the conflicts? This fix would be appreciated! |
|
Hi @MorenoMdz. Does the update @johnbeynon made in 4545b7c cover your needs? This PR may be OK to close. |
|
For me it still shows success in the job even when it 401. |

When error responses are received from the Render API it doesn't fail the job. I noticed this when encountering a 401 error upon first getting this setup. So this uses
Response.okto check if the response is successful, otherwise fails the job.Also, I have been wanting a bit more output showing what Render responds with when triggering a deploy. Not 100% sure what's best for the output here, but the this should be a bit more useful.
e.g