n8n-io/n8n · error · NodeOperationError
The file "${fileName}" is ${sizeInMb} MB, which exceeds the
Error message
The file "${fileName}" is ${sizeInMb} MB, which exceeds the ${limitInMb} MB limit for passing binary data to the model What it means
Thrown by addPassthroughBinary (Tools Agent common.ts) when a binary item being passed through to the model exceeds the configured size cap. The limit defaults to DEFAULT_MAX_PASSTHROUGH_BINARY_SIZE_BYTES and is overridable via the AiConfig.maxAgentPassthroughBinarySizeBytes field, which in turn reads N8N_AI_AGENT_MAX_PASSTHROUGH_BINARY_SIZE_BYTES. The check uses Buffer.byteLength on the decoded base64 to measure true size, and the error message reports both the file size and the limit in MB.
Source
Thrown at packages/@n8n/nodes-langchain/nodes/agents/Agent/agents/ToolsAgent/common.ts:164
base64Data = Buffer.from(binaryBuffer).toString(BINARY_ENCODING);
} else {
base64Data = data.data.includes('base64,') ? data.data.split('base64,')[1] : data.data;
}
// Guard against oversized attachments. Providers that accept inline (base64)
// documents cap the request payload, so we reject early with a clear message
// instead of surfacing an opaque provider-side error. The limit is
// configurable via N8N_AI_AGENT_MAX_PASSTHROUGH_BINARY_SIZE_BYTES.
const maxSizeInBytes =
Container.get(AiConfig)?.maxAgentPassthroughBinarySizeBytes ??
DEFAULT_MAX_PASSTHROUGH_BINARY_SIZE_BYTES;
// Decode the base64 length exactly (Buffer.byteLength accounts for padding).
const sizeInBytes = Buffer.byteLength(base64Data, 'base64');
if (sizeInBytes > maxSizeInBytes) {
const fileName = data.fileName ?? 'binary file';
const sizeInMb = (sizeInBytes / (1024 * 1024)).toFixed(1);
const limitInMb = (maxSizeInBytes / (1024 * 1024)).toFixed(1);
throw new NodeOperationError(
ctx.getNode(),
`The file "${fileName}" is ${sizeInMb} MB, which exceeds the ${limitInMb} MB limit for passing binary data to the model`,
{
description:
'Reduce the file size, or disable the binary passthrough option for this input.',
},
);
}
// PDFs (and other documents) are passed as a file content block. OpenAI's
// Responses API needs its native `input_file` part; every other supported
// provider consumes the LangChain standard data content block.
if (type === 'file') {
if (contentFormat === 'openai-responses') {
return {
type: 'input_file',
file_data: `data:${data.mimeType};base64,${base64Data}`,
filename: data.fileName ?? 'attachment.pdf',View on GitHub (pinned to 5ac6606e81)
Solutions
- Reduce the input file size before it reaches the agent (compress the image, split the PDF, or downscale).
- Disable the 'passthroughBinaryImages' / 'passthroughBinaryPdfs' option if binary passthrough is not required.
- Raise the limit by setting N8N_AI_AGENT_MAX_PASSTHROUGH_BINARY_SIZE_BYTES in the environment (self-hosted only), mindful of provider payload limits.
Example fix
// before — oversized binary reaches the agent and trips the guard
// after — gate passthrough by size upstream
const MAX = 20 * 1024 * 1024;
const items = [];
for (const item of $input.all()) {
const b = item.binary?.data;
if (b && Buffer.from(b.data, 'base64').length > MAX) {
// drop binary, keep text only
const { data, ...rest } = item;
items.push({ json: item.json, binary: undefined });
} else {
items.push(item);
}
}
return items; Defensive patterns
Strategy: validation
Validate before calling
const limit = Container.get(AiConfig)?.maxAgentPassthroughBinarySizeBytes ?? DEFAULT_MAX_PASSTHROUGH_BINARY_SIZE_BYTES;
for (const item of items) {
for (const key of Object.keys(item.binary ?? {})) {
const b = item.binary[key];
const buf = b.id ? await ctx.helpers.binaryToBuffer(await ctx.helpers.getBinaryStream(b.id)) : Buffer.from(b.data, 'base64');
if (buf.length > limit) {
throw new NodeOperationError(ctx.getNode(), `Binary '${key}' (${(buf.length/1048576).toFixed(1)} MB) exceeds the ${(limit/1048576).toFixed(1)} MB passthrough limit.`);
}
}
} Type guard
function isWithinBinaryLimit(buf: Buffer, limit: number): boolean {
return buf.length <= limit;
} Prevention
- Compress or split large files before they reach the agent.
- Disable passthroughBinaryImages / passthroughBinaryPdfs when not needed.
- Tune N8N_AI_AGENT_MAX_PASSTHROUGH_BINARY_SIZE_BYTES only with awareness of provider payload limits.
When it happens
Trigger: passthroughBinaryImages or passthroughBinaryPdfs is enabled on the Agent, and an incoming item carries a binary file (image/PDF) whose decoded size exceeds the configured limit. The model would otherwise receive an oversized payload and the provider would reject it opaquely.
Common situations: Large PDF or high-res image attached to the trigger; default limit too low for the use case; user enabled binary passthrough without sizing the inputs.
Related errors
- No binary data found, please connect a binary to the input i
- No binary data received.
- Please connect a model to the Fallback Model input or disabl
- Please connect a model to the Fallback Model input or disabl
- Tools Agent requires Chat Model which supports Tools calling
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/07d836926733d769.
Report an issue: GitHub.