n8n-io/n8n · error · UnsupportedMimeTypeError
${binaryData.mimeType} is not a supported type of binary dat
Error message
${binaryData.mimeType} is not a supported type of binary data. Only images are supported. What it means
UnsupportedMimeTypeError (a subclass of OperationalError) is thrown by dataUriFromImageData when the supplied IBinaryData's mimeType does not begin with 'image/'. Vision-capable language models only accept image content, so the helper refuses to base64-encode a non-image file into a data URI.
Source
Thrown at packages/@n8n/nodes-langchain/nodes/chains/ChainLLM/methods/imageUtils.ts:17
import type { BaseLanguageModel } from '@langchain/core/language_models/base';
import { HumanMessage } from '@langchain/core/messages';
import { ChatGoogleGenerativeAI } from '@langchain/google-genai';
import { ChatOllama } from '@langchain/ollama';
import type { IExecuteFunctions, IBinaryData } from 'n8n-workflow';
import { NodeOperationError, NodeConnectionTypes, OperationalError } from 'n8n-workflow';
import type { MessageTemplate } from './types';
export class UnsupportedMimeTypeError extends OperationalError {}
/**
* Converts binary image data to a data URI
*/
export function dataUriFromImageData(binaryData: IBinaryData, bufferData: Buffer): string {
if (!binaryData.mimeType?.startsWith('image/')) {
throw new UnsupportedMimeTypeError(
`${binaryData.mimeType} is not a supported type of binary data. Only images are supported.`,
);
}
return `data:${binaryData.mimeType};base64,${bufferData.toString('base64')}`;
}
/**
* Creates a human message with image content from either binary data or URL
*/
export async function createImageMessage({
context,
itemIndex,
message,
}: {
context: IExecuteFunctions;
itemIndex: number;
message: MessageTemplate;
}): Promise<HumanMessage> {View on GitHub (pinned to 5ac6606e81)
Solutions
- Verify the binary file is actually an image (PNG, JPEG, GIF, WEBP) by checking $json.<key>.mimeType before the chain runs.
- Point the node's binaryImageDataKey at the correct image property instead of a document/attachment property.
- Pre-process non-image files: convert PDFs to images, or use a text-extraction node to get text instead of sending the binary as an image.
- Filter items by mimeType upstream with an If node ({{ $binary.data.mimeType.startsWith('image/') }}).
Example fix
// before — assumes any binary is an image
const dataURI = dataUriFromImageData(binaryData, bufferData);
// after — guard before calling
if (!binaryData.mimeType?.startsWith('image/')) {
throw new NodeOperationError(context.getNode(), {
message: `Expected an image, got ${binaryData.mimeType}. Convert the file to an image first.`,
});
}
const dataURI = dataUriFromImageData(binaryData, bufferData); Defensive patterns
Strategy: validation
Validate before calling
// Validate mimeType before passing binary data to an image message
function isImageBinary(b: { mimeType?: string } | undefined): b is { mimeType: string } {
return !!b?.mimeType?.startsWith('image/');
}
// usage
if (!isImageBinary(item.binary?.[key])) {
// route to a non-image path or filter the item out
} Type guard
function isImageBinary(b: { mimeType?: string } | undefined): b is { mimeType: string } {
return typeof b?.mimeType === 'string' && b.mimeType.startsWith('image/');
} Try / catch
try {
const dataURI = dataUriFromImageData(binaryData, bufferData);
} catch (e) {
if (e instanceof UnsupportedMimeTypeError) {
// handle: skip item, convert file, or notify user
} else throw e;
} Prevention
- Filter items by $binary.<key>.mimeType.startsWith('image/') in an If node upstream.
- Use a converter node for PDFs/documents before sending to a vision chain.
- Confirm the upstream node is reading the file as an image format.
When it happens
Trigger: A binary property holding a PDF, video, audio file, or any non-image MIME type is passed as the binaryImageDataKey to createImageMessage / dataUriFromImageData. The check binaryData.mimeType?.startsWith('image/') returns false and the error is raised.
Common situations: User connected a 'Read Binary File' or HTTP file download to the image input of a ChainLLM Basic LLM Chain configured for vision, but the file is a PDF or document. The binary key on the item exists and is populated, but its content is not an image.
Related errors
- Invalid message type. Only imageBinary and imageUrl are supp
- No binary data set.
- Content not viewable
- Unsupported attachment type: ${summary}
- The ‘text‘ parameter is empty.
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/beceefc5b4a2ffb2.
Report an issue: GitHub.