{"record":{"id":"72c65d2f9bc71758","repo":"payloadcms/payload","slug":"attachment-is-missing-filename","errorCode":null,"errorMessage":"Attachment is missing filename","messagePattern":"Attachment is missing filename","errorType":"validation","errorClass":"APIError","httpStatus":400,"severity":"error","filePath":"packages/email-resend/src/index.ts","lineNumber":152,"sourceCode":"  }\n\n  if (Array.isArray(addresses)) {\n    return addresses.map((address) => (typeof address === 'string' ? address : address.address))\n  }\n\n  return [addresses.address]\n}\n\nfunction mapAttachments(\n  attachments: SendEmailOptions['attachments'],\n): ResendSendEmailOptions['attachments'] {\n  if (!attachments) {\n    return []\n  }\n\n  return attachments.map((attachment): Attachment => {\n    if (!attachment.filename) {\n      throw new APIError('Attachment is missing filename', 400)\n    }\n\n    if (!attachment.content && !attachment.path) {\n      throw new APIError('Attachment is missing both content and path', 400)\n    }\n\n    // When both content and path are provided, content takes priority; path is ignored.\n    if (attachment.path && !attachment.content) {\n      const path = typeof attachment.path === 'string' ? attachment.path : attachment.path.href\n      return {\n        filename: attachment.filename,\n        path,\n      }\n    }\n\n    if (typeof attachment.content === 'string') {\n      return {\n        content: attachment.content,","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/email-resend/src/index.ts#L134-L170","documentation":"Thrown by mapAttachments in the Resend adapter when an attachment object is missing the required `filename` field. Resend's API requires a filename for every attachment, so the adapter validates this before building the request rather than letting Resend reject the whole send.","triggerScenarios":"Calling payload.sendEmail with `attachments: [{ content: buffer }]` (no filename), or constructing attachments dynamically where the filename key is omitted/undefined.","commonSituations":"Building attachments from uploaded files and forgetting to map the original name to filename; renaming fields and missing one code path; attachments coming from a third-party payload that omits filename.","solutions":["Ensure every attachment object includes a `filename` string (including extension).","Default filename to a sensible value (e.g. originalname or 'attachment.bin') when the source object omits it.","Validate the attachments array shape before calling payload.sendEmail."],"exampleFix":"// before\nattachments: [{ content: buf }]\n// after\nattachments: [{ filename: 'report.pdf', content: buf }]","handlingStrategy":"validation","validationCode":"function normalizeAttachments(attachments) {\n  return (attachments || []).map(a => {\n    if (!a.filename) throw new Error('Attachment is missing filename')\n    return a\n  })\n}","typeGuard":"const attachmentHasFilename = (a) => Boolean(a && a.filename)","tryCatchPattern":null,"preventionTips":["Default filename to originalname (or 'attachment') when mapping uploads to attachments.","Validate the attachments array shape before calling payload.sendEmail."],"tags":["email","resend","attachments","validation"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}