-
-
Notifications
You must be signed in to change notification settings - Fork 682
Description
Bug Description
Webhook notifications fail silently with the error:
Error sending webhook notification {"type":"MEDIA_AVAILABLE","subject":"...","errorMessage":"\"[object Object]\" is not valid JSON"}
This affects any webhook configuration saved through the API or UI. The default webhook payload works correctly because it is hardcoded as a double-encoded base64 string, but user-customized payloads break immediately.
Root Cause
In server/lib/notifications/agents/webhook.ts, buildPayload() double-parses the stored JSON payload:
const parsedJSON = JSON.parse(JSON.parse(payloadString));This expects the base64-decoded string to be a JSON-encoded string (i.e., a string value that itself contains JSON). The first JSON.parse unwraps the outer string, and the second parses the inner JSON.
However, the save routes in server/routes/settings/notifications.ts (POST /webhook and POST /webhook/test) only single-encode:
jsonPayload: Buffer.from(req.body.options.jsonPayload).toString("base64")This stores the raw JSON string directly in base64. When buildPayload double-parses it:
- First
JSON.parse: parses the JSON string → produces a JS object - Second
JSON.parse: calls.toString()on the object →"[object Object]"→ fails
Steps to Reproduce
- Go to Settings → Notifications → Webhook
- Configure a webhook URL and save (with any JSON payload)
- Click "Test" or trigger any notification (media request, approval, etc.)
- Check logs:
"[object Object]" is not valid JSON
Expected Behavior
Webhook notifications should be sent successfully after saving via the UI/API.
Fix
The save routes should wrap the payload with JSON.stringify() before base64-encoding, matching the double-encoded format that buildPayload expects:
jsonPayload: Buffer.from(JSON.stringify(req.body.options.jsonPayload)).toString("base64")PR: #(incoming)
Environment
- Seerr version: 3.1.0 (also present in current
developbranch) - Affects: all webhook configurations saved via API/UI