jellyseerr icon indicating copy to clipboard operation
jellyseerr copied to clipboard

Webhooks error when containing unicode characters

Open joshuaboniface opened this issue 1 year ago • 2 comments

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

  1. Create a generic webhook ("Settings" -> "Notifications" -> "Webhook").

  2. Populate a valid webhook with an emoji (e.g. 🚀) in the body:

    {
     "text": "🚀 Jellyseer {{notification_type}}: New request for {{media}} from @{{requestedBy_username}}"
    }
    
  3. 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

joshuaboniface avatar Apr 12 '24 14:04 joshuaboniface

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.

joshuaboniface avatar Apr 12 '24 14:04 joshuaboniface

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.

joshuaboniface avatar Apr 12 '24 14:04 joshuaboniface

:tada: This issue has been resolved in version 1.9.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

fallenbagel avatar May 29 '24 14:05 fallenbagel