Outgoing webhooks should catch `JsonableError` when posting messages
See original GitHub issueResponses to outgoing webhook replies can be JSON data which is used to post an immediate response. Mostly this consists of a content key, but also currently supports an undocumented widget_content key as well. If the content or widget_content fails validation (e.g. content contains nulls, or widget_content is not a string which contains JSON(! ?)) in check_message in zerver/lib/actions.py, it raises a JsonableError. Unfortunately, the outgoing webook does not catch this, and it bubbles up and fails at the queue worker level: https://sentry.io/share/issue/dbf8873365814ed29f8860e0215eb533/
We should catch JsonableError inside the try/catch block we already have in do_rest_call. Ideally we should use also notify_bot_owner to inform the bot of the exception that was raised.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)

Top Related StackOverflow Question
Ah! Sorry for not seeing that PR at the time. I’ve left some comments there. @edith007, it sounds like this issue is fairly well in hand, so best to find something else that catches your eye. 😃
Hm, I see there was some work on this already once. I’m not sure why @sundargs2000 closed their PR – it was a good start in the right direction. I’m sorry it didn’t get a prompt review, Sundar! We can give it a proper review if you want to re-open it.
@edith007, if @sundargs2000 doesn’t want to pick this back up, or we don’t hear back in a couple of days, I can assign it to you.