Skip to content

Webhook notifications fail with "[object Object] is not valid JSON" after saving via API/UI #2640

@aldoeliacim

Description

@aldoeliacim

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:

  1. First JSON.parse: parses the JSON string → produces a JS object
  2. Second JSON.parse: calls .toString() on the object → "[object Object]"fails

Steps to Reproduce

  1. Go to Settings → Notifications → Webhook
  2. Configure a webhook URL and save (with any JSON payload)
  3. Click "Test" or trigger any notification (media request, approval, etc.)
  4. 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 develop branch)
  • Affects: all webhook configurations saved via API/UI

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions