Sendgrid-nodejs: attachments throw error for optional fields

Created on 7 Aug 2020  路  4Comments  路  Source: sendgrid/sendgrid-nodejs

Issue Summary

When adding an attachment with just filename and content (both required), the library throws an error "Expected the attachment's type field to be a string". Type is not required per the spec here https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/index.html

Steps to Reproduce

  1. create new message packet
  2. set one attachment to the message packet with only { content, filename }
  3. call SG.send(messagePacket)

Code Snippet


const data = {
  personalizations: [{ to: [{ email: '[email protected]' }] }'],
  from: {
    email: '[email protected]',
  },
  subject: 'subject',
  template_id: 'd-111111111111',
  atttachments: [{
    content: 'blah blah',
    filename: 'test.txt',
  }]
}
await sgMail.send(data);

Exception/Log

" at Mail.setAttachments (/app/node_modules/@sendgrid/helpers/classes/mail.js:445:13)", " at Mail.fromData (/app/node_modules/@sendgrid/helpers/classes/mail.js:82:10)", " at new Mail (/app/node_modules/@sendgrid/helpers/classes/mail.js:46:12)", " at Function.create (/app/node_modules/@sendgrid/helpers/classes/mail.js:670:12)", " at MailService.send (/app/node_modules/@sendgrid/mail/src/classes/mail-service.js:188:25)",

Technical details:

  • sendgrid-nodejs version: 7.2.3
  • node version: v12.18.1
bug

Most helpful comment

This issue has been added to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog.

All 4 comments

This issue has been added to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog.

Same issue with disposition field: https://github.com/sendgrid/sendgrid-nodejs/issues/1179

This issue should have been resolved by https://github.com/sendgrid/sendgrid-nodejs/pull/1198, which hasn't been released yet released

@TheOptimisticFactory Thanks! Forget to check linked issues. Closing as the work is done and this will be released later today.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TobiahRex picture TobiahRex  路  3Comments

Chrischuck picture Chrischuck  路  3Comments

metalshan picture metalshan  路  3Comments

prasoonjalan picture prasoonjalan  路  3Comments

thinkingserious picture thinkingserious  路  4Comments