{"record":{"id":"dc0d73b54585beaf","repo":"n8n-io/n8n","slug":"unsupported-file-type-mimetype-only-images-an","errorCode":null,"errorMessage":"Unsupported file type: ${mimeType}. Only images and PDFs are supported.","messagePattern":"Unsupported file type: (.+?)\\. Only images and PDFs are supported\\.","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/vendors/Anthropic/actions/text/message.operation.ts","lineNumber":307,"sourceCode":"\tblockedDomains?: string;\n\tmaxUses?: number;\n\tmaxTokens?: number;\n\tsystem?: string;\n\ttemperature?: number;\n\ttopP?: number;\n\ttopK?: number;\n}\n\nfunction getFileTypeOrThrow(this: IExecuteFunctions, mimeType?: string): 'image' | 'document' {\n\tif (mimeType?.startsWith('image/')) {\n\t\treturn 'image';\n\t}\n\n\tif (mimeType === 'application/pdf') {\n\t\treturn 'document';\n\t}\n\n\tthrow new NodeOperationError(\n\t\tthis.getNode(),\n\t\t`Unsupported file type: ${mimeType}. Only images and PDFs are supported.`,\n\t);\n}\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst model = this.getNodeParameter('modelId', i, '', { extractValue: true }) as string;\n\tconst rawMessages = this.getNodeParameter('messages.values', i, []) as Message[];\n\tconst addAttachments = this.getNodeParameter('addAttachments', i, false) as boolean;\n\tconst simplify = this.getNodeParameter('simplify', i, true) as boolean;\n\tconst options = this.getNodeParameter('options', i, {}) as MessageOptions;\n\n\tconst messages = rawMessages.filter(\n\t\t(m) => typeof m.content !== 'string' || m.content.trim() !== '',\n\t);\n\n\tif (!addAttachments && messages.length === 0) {\n\t\tthrow new NodeOperationError(this.getNode(), 'A non-empty prompt is required.', {","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vendors/Anthropic/actions/text/message.operation.ts#L289-L325","documentation":"Thrown by getFileTypeOrThrow in the Anthropic text/message operation when a binary attachment's MIME type is neither an image type (image/*) nor application/pdf. The function maps MIME types to Anthropic content types; Anthropic's Messages API only accepts images and PDF documents as attachments, so any other file type is rejected before the API call.","triggerScenarios":"A binary attachment in the input data has a MIME type that does not start with 'image/' and is not 'application/pdf'. For example: text/plain, application/vnd.openxmlformats-officedocument.wordprocessingml.document (.docx), video/mp4, audio/mpeg, application/json, etc. The error fires when addAttachments is true and the attachment's MIME type is read from the binary metadata.","commonSituations":"Upstream node produces a non-image/non-PDF file (e.g. a Word doc, CSV, video) that the user tries to attach to an Anthropic message; binary data was uploaded with a generic 'application/octet-stream' MIME type; the MIME type detection in an upstream node is incorrect.","solutions":["Check the MIME type of the binary data in the input item — the error message includes the actual mimeType value.","Convert the attachment to PNG/JPEG (for images) or PDF (for documents) using an upstream conversion node before passing it to the Anthropic node.","If the file is actually an image or PDF but has a wrong MIME type, fix the upstream node that sets the binary metadata.","Remove non-image/non-PDF attachments from the input or disable 'Add Attachments' for items with unsupported file types."],"exampleFix":"// before — upstream node sets binary MIME type to 'application/octet-stream'\n// for what is actually a PNG image\n\n// after — set correct MIME type in the upstream node's binary output\n// binary.mimeType = 'image/png'","handlingStrategy":"type-guard","validationCode":"// Before passing attachments, validate MIME types:\nconst SUPPORTED_PREFIXES = ['image/'];\nconst SUPPORTED_EXACT = ['application/pdf'];\nfunction isSupportedMimeType(mimeType: string): boolean {\n  return SUPPORTED_PREFIXES.some(p => mimeType.startsWith(p)) || SUPPORTED_EXACT.includes(mimeType);\n}\n// In an upstream Code node, filter out unsupported attachments:\nconst filteredItems = items.filter(item => {\n  const binary = item.binary;\n  if (!binary) return true; // no binary to check\n  return Object.values(binary).every(b => isSupportedMimeType(b.mimeType));\n});","typeGuard":"function isAnthropicSupportedMimeType(mime: string): boolean {\n  return mime.startsWith('image/') || mime === 'application/pdf';\n}","tryCatchPattern":null,"preventionTips":["Convert documents to PDF and images to PNG/JPEG in an upstream node before attaching.","Verify binary MIME types are set correctly by upstream nodes — avoid generic 'application/octet-stream'.","Use a Switch node upstream to route unsupported file types away from the Anthropic node.","When reading files from disk, set the correct MIME type explicitly."],"tags":["attachments","mime-type","anthropic","validation"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}