jellyseerr
jellyseerr copied to clipboard
Webhooks error when containing unicode characters
Description
When creating a generic webhook, attempting to send unicode characters (e.g. emoji) in the payload throws an error:
2024-04-12T14:16:04.225Z [error][Notifications]: Error sending webhook notification {"type":"TEST_NOTIFICATION","subject":"Test Notification","errorMessage":"Unexpected token \u001f in JSON at position 77"}
Version
develop
Steps to Reproduce
-
Create a generic webhook ("Settings" -> "Notifications" -> "Webhook").
-
Populate a valid webhook with an emoji (e.g. 🚀) in the body:
{ "text": "🚀 Jellyseer {{notification_type}}: New request for {{media}} from @{{requestedBy_username}}" } -
Click "Test" and see the error above in the logs.
Screenshots
No response
Logs
2024-04-12T14:16:33.477Z [debug][Notifications]: Sending webhook notification {"type":"TEST_NOTIFICATION","subject":"Test Notification"}
2024-04-12T14:16:33.479Z [error][Notifications]: Error sending webhook notification {"type":"TEST_NOTIFICATION","subject":"Test Notification","errorMessage":"Unexpected token \u001f in JSON at position 77"}
Platform
desktop
Device
Web
Operating System
Debian GNU/Linux 12.x
Browser
Firefox
Additional Context
No response
Code of Conduct
- [X] I agree to follow Jellyseerr's Code of Conduct
I suspect the issue is here: https://github.com/Fallenbagel/jellyseerr/blob/develop/server/lib/notifications/agents/webhook.ts#L144
The input text is converted to an ascii string, which precludes any unicode characters.
I've attempted to change this to utf8 in my local develop copy, and this seems to work as expected, though I'm not sure about the implications of this change. Though this is original code (from a7cc7c597) so I suspect that changing it is fine.
https://github.com/Fallenbagel/jellyseerr/blob/develop/server/routes/settings/notifications.ts#L278 would also need to change, and doing so seems to work flawlessly.
:tada: This issue has been resolved in version 1.9.0 :tada:
The release is available on:
v1.9.0- GitHub release
Your semantic-release bot :package::rocket: