NovuN
Novu10mo ago
r2d2

422 Unprocessable Entity When Sending Attachments via Novu API

@Pawan Jain

Description
When executing a job in the Novu queue, I encounter a 500 Internal Server Error with an UnknownBridgeRequestError message. The error occurs when Novu tries to call a bridge request to http://api.novu.local:3000/v1/environments/{ENV_ID}/bridge.

await novu.trigger('assessment-results', {
  to: {
    subscriberId: '123456',
    email: 'user@example.com',
  },
  payload: {
    studentName: 'John Doe',
    assessmentDate: 'March 11',
    oldEnglishLevel: 'B1+',
    newEnglishLevel: 'B2-',
    goodFeedback: 'Excellent use of verb tenses',
    toImproveFeedback: 'Pronunciation and vocabulary',
    attachments: [
      {
        file: certificateBuffer,
        name: 'certificate.pdf',
        mime: 'application/pdf',
      },
    ],
  },
});


The job enters the queue but fails to execute with the following error:
{
  "url": "http://api.novu.local:3000/v1/environments/67b760905c73e5e854203937/bridge",
  "statusCode": 500,
  "message": "Unknown bridge request error calling `http://api.novu.local:3000/v1/environments/67b760905c73e5e854203937/bridge`",
  "code": "UnknownBridgeRequestError",
  "cause": {
    "name": "HTTPError",
    "code": "ERR_NON_2XX_3XX_RESPONSE",
    "timings": {
      "start": 1742399460159,
      "socket": 1742399460161,
      "lookup": 1742399460161,
      "connect": 1742399460161,
      "upload": 1742399460164,
      "response": 1742399460174,
      "end": 1742399460174,
      "phases": {
        "wait": 2,
        "dns": 0,
        "tcp": 0,
        "request": 3,
        "firstByte": 10,
        "download": 0,
        "total": 15
      }
    }
  }
}
image.png
Was this page helpful?