n8n-io/n8n · error · Error

Attachment exceeds maximum size of

Error message

Attachment exceeds maximum size of ${formatMB(MAX_DECODED_SIZE_BYTES)} (got ${formatMB(actualBytes)})

What it means

Pre-flight size guard in extractDocxText: the base64-decoded docx buffer exceeds MAX_DECODED_SIZE_BYTES. The limit is checked before decompression/parsing so an oversized attachment fails cheaply instead of exhausting memory in mammoth. The fault is the attachment's decoded size, not its content.

Solutions

  1. Trim or split the document and re-attach it below the decoded-size limit
  2. Compress embedded media (images are the usual bulk in docx) before attaching
  3. Link to the file in cloud storage instead of attaching it when it must stay large
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/@n8n/instance-ai/src/parsers/docx-parser.ts:20 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at packages/@n8n/instance-ai/src/parsers/docx-parser.ts:20

import {
	MAX_DECODED_SIZE_BYTES,
	MAX_RESULT_CHARS,
	formatSizeLimitMessage,
	type AttachmentInfo,
} from './structured-file-parser';

export interface DocxExtractionResult {
	text: string;
	truncated: boolean;
}

/**
 * Extracts plain text from a `.docx` (Office Open XML) attachment using `mammoth`.
 */
export async function extractDocxText(attachment: AttachmentInfo): Promise<DocxExtractionResult> {
	const decoded = Buffer.from(attachment.data, 'base64');
	if (decoded.length > MAX_DECODED_SIZE_BYTES) {
		throw new Error(formatSizeLimitMessage(decoded.length));
	}
	assertOoxmlWithinBounds(decoded, attachment.fileName);

	const mammoth = await import('mammoth');
	const extractRawText = mammoth.extractRawText ?? mammoth.default?.extractRawText;
	if (typeof extractRawText !== 'function') {
		throw new Error('mammoth.extractRawText is not available');
	}

	let raw: { value: string };
	try {
		raw = await extractRawText({ buffer: decoded });
	} catch (error) {
		const message = error instanceof Error ? error.message : 'unknown error';
		throw new Error(`Failed to parse docx "${attachment.fileName}": ${message}`);
	}

	const text = raw.value?.trim() ?? '';

View on GitHub (pinned to 5ac6606e81)