You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypeError: err.toJSON is not a function when webhook URL is invalid #511
This took a bit for me to track down (my own mistake), thanks to the real error not being shown in the action. If, for example, I accidentally quote the webhook URL, like:
Run slackapi/slack-github-action@v2
Error: TypeError: err.toJSON is not a function
Error: err.toJSON is not a function
TypeError: err.toJSON is not a function
at Webhook.post (file:///home/runner/work/_actions/slackapi/slack-github-action/v2/src/webhook.js:36:1)
at post (file:///home/runner/work/_actions/slackapi/slack-github-action/v2/src/send.js:35:1)
at send (file:///home/runner/work/_actions/slackapi/slack-github-action/v2/src/send.js:15:1)
at file:///home/runner/work/_actions/slackapi/slack-github-action/v2/src/index.js:9:1
file:///home/runner/work/_actions/slackapi/slack-github-action/v2/src/webhook.js:36
const response = err.toJSON();
^
TypeError: err.toJSON is not a function
at Webhook.post (file:///home/runner/work/_actions/slackapi/slack-github-action/v2/src/webhook.js:36:1)
at post (file:///home/runner/work/_actions/slackapi/slack-github-action/v2/src/send.js:35:1)
at send (file:///home/runner/work/_actions/slackapi/slack-github-action/v2/src/send.js:15:1)
at file:///home/runner/work/_actions/slackapi/slack-github-action/v2/src/index.js:9:1
It looks like the catch block is assuming the exception will always have a toJSON function, but in my case it obviously doesn't.
The fix of course, was to remove the erroneous toJSON(...) wrapper from the webhook input, but it would have saved me a lot of time if the exception was handled better by thi action.
Note, the err.toJSON in the exception is unrelated to the toJSON in my input - its only coincidental that we both used (different) toJSON functions (JavaScript vs GitHub Expression respectively).
Oof, this must have taken some time to track down. Sorry that we put that on you. 🙇🏻
We've had a few iterations to surface the right level of errors in the GitHub Action and I think you've found an edge-case. Thanks a lot for the details, code example, and resolution. I think this goes a long way in helping us reproduce it and patch it.
@zimeg Since you've made big strides in improving the errors, what are your thoughts on this one?
Activity
mwbrooks commentedon Nov 17, 2025
Hi @pcolby 👋🏻
Oof, this must have taken some time to track down. Sorry that we put that on you. 🙇🏻
We've had a few iterations to surface the right level of errors in the GitHub Action and I think you've found an edge-case. Thanks a lot for the details, code example, and resolution. I think this goes a long way in helping us reproduce it and patch it.
@zimeg Since you've made big strides in improving the errors, what are your thoughts on this one?
mwbrooks commentedon Nov 22, 2025
@pcolby I had a chat with @zimeg async and they agree that it's a bug 🐛 So we'll keep this issue open and follow-up with a PR.
Thanks again for taking the time to submit the issue and workaround! 🙇🏻
fix: handle webhook errors without toJSON (fixes slackapi#511)