n8n-io/n8n · error · NodeOperationError

Unsupported file type: ${mimeType}. Only images and PDFs are

Error message

Unsupported file type: ${mimeType}. Only images and PDFs are supported.

What it means

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.

Source

Thrown at packages/@n8n/nodes-langchain/nodes/vendors/Anthropic/actions/text/message.operation.ts:307

	blockedDomains?: string;
	maxUses?: number;
	maxTokens?: number;
	system?: string;
	temperature?: number;
	topP?: number;
	topK?: number;
}

function getFileTypeOrThrow(this: IExecuteFunctions, mimeType?: string): 'image' | 'document' {
	if (mimeType?.startsWith('image/')) {
		return 'image';
	}

	if (mimeType === 'application/pdf') {
		return 'document';
	}

	throw new NodeOperationError(
		this.getNode(),
		`Unsupported file type: ${mimeType}. Only images and PDFs are supported.`,
	);
}

export async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {
	const model = this.getNodeParameter('modelId', i, '', { extractValue: true }) as string;
	const rawMessages = this.getNodeParameter('messages.values', i, []) as Message[];
	const addAttachments = this.getNodeParameter('addAttachments', i, false) as boolean;
	const simplify = this.getNodeParameter('simplify', i, true) as boolean;
	const options = this.getNodeParameter('options', i, {}) as MessageOptions;

	const messages = rawMessages.filter(
		(m) => typeof m.content !== 'string' || m.content.trim() !== '',
	);

	if (!addAttachments && messages.length === 0) {
		throw new NodeOperationError(this.getNode(), 'A non-empty prompt is required.', {

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Check the MIME type of the binary data in the input item — the error message includes the actual mimeType value.
  2. Convert the attachment to PNG/JPEG (for images) or PDF (for documents) using an upstream conversion node before passing it to the Anthropic node.
  3. If the file is actually an image or PDF but has a wrong MIME type, fix the upstream node that sets the binary metadata.
  4. Remove non-image/non-PDF attachments from the input or disable 'Add Attachments' for items with unsupported file types.

Example fix

// before — upstream node sets binary MIME type to 'application/octet-stream'
// for what is actually a PNG image

// after — set correct MIME type in the upstream node's binary output
// binary.mimeType = 'image/png'
Defensive patterns

Strategy: type-guard

Validate before calling

// Before passing attachments, validate MIME types:
const SUPPORTED_PREFIXES = ['image/'];
const SUPPORTED_EXACT = ['application/pdf'];
function isSupportedMimeType(mimeType: string): boolean {
  return SUPPORTED_PREFIXES.some(p => mimeType.startsWith(p)) || SUPPORTED_EXACT.includes(mimeType);
}
// In an upstream Code node, filter out unsupported attachments:
const filteredItems = items.filter(item => {
  const binary = item.binary;
  if (!binary) return true; // no binary to check
  return Object.values(binary).every(b => isSupportedMimeType(b.mimeType));
});

Type guard

function isAnthropicSupportedMimeType(mime: string): boolean {
  return mime.startsWith('image/') || mime === 'application/pdf';
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12). Data as JSON: /api/errors/dc0d73b54585beaf. Report an issue: GitHub.