Skip to content

fix: handle webhook errors without toJSON#579

Open
saschabuehrle wants to merge 1 commit intoslackapi:mainfrom
saschabuehrle:fix/issue-511-handle-nonaxios-errors
Open

fix: handle webhook errors without toJSON#579
saschabuehrle wants to merge 1 commit intoslackapi:mainfrom
saschabuehrle:fix/issue-511-handle-nonaxios-errors

Conversation

@saschabuehrle
Copy link

Fixes #511

Webhook.post currently assumes every thrown error implements toJSON(). That crashes error handling itself for non-Axios errors (for example invalid webhook input), hiding the original cause.

This change adds a safe fallback when toJSON is not available, preserves status/message outputs, and throws SlackError with a cause so the root error is still available.

Also adds a regression test for a non-Axios TypeError path.

Greetings, saschabuehrle

@saschabuehrle saschabuehrle requested a review from a team as a code owner March 24, 2026 09:49
@salesforce-cla
Copy link

Thanks for the contribution! Before we can merge this, we need @saschabuehrle to sign the Salesforce Inc. Contributor License Agreement.

@zimeg zimeg closed this Mar 24, 2026
@zimeg zimeg reopened this Mar 24, 2026
@zimeg
Copy link
Member

zimeg commented Mar 24, 2026

👋 Hey @saschabuehrle! Thanks so much for taking the time to send this in!

Before reviewing the changes, can I ask you to sign the CLA linked above? It's required as part of our contribution process 🏛️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError: err.toJSON is not a function when webhook URL is invalid

2 participants