n8n-io/n8n · warning · Error
Content too large: ${byteSize} bytes (max ${MAX_FILE_SIZE} b
Error message
Content too large: ${byteSize} bytes (max ${MAX_FILE_SIZE} bytes). What it means
Thrown by write_file when the content's UTF-8 byte length exceeds MAX_FILE_SIZE (1 MB). The check uses Buffer.byteLength(content, 'utf-8'), which counts bytes not characters — so multi-byte UTF-8 characters (emoji, CJK, etc.) each count as 2-4 bytes. The guard runs before any filesystem write occurs.
Source
Thrown at packages/@n8n/computer-use/src/tools/filesystem/write-file.ts:31
});
export const writeFileTool: ToolDefinition<typeof inputSchema> = {
name: 'write_file',
description:
'Create a new file with the given content. Overwrites if the file already exists. Content must not exceed 1 MB.',
inputSchema,
annotations: {},
async getAffectedResources({ filePath }, { dir }) {
return [
await buildFilesystemResource(dir, filePath, 'filesystemWrite', `Write file: ${filePath}`),
];
},
async execute({ filePath, content }, { dir }) {
const resolvedPath = await resolveSafePath(dir, filePath);
const byteSize = Buffer.byteLength(content, 'utf-8');
if (byteSize > MAX_FILE_SIZE) {
throw new Error(`Content too large: ${byteSize} bytes (max ${MAX_FILE_SIZE} bytes).`);
}
await fs.mkdir(path.dirname(resolvedPath), { recursive: true });
await fs.writeFile(resolvedPath, content, 'utf-8');
return formatCallToolResult({ path: filePath });
},
};
View on GitHub (pinned to 5ac6606e81)
Solutions
- Split the content into multiple smaller files, each under 1 MB
- Reduce the content size by removing unnecessary data or using a more compact format
- Use shell tools to write large files via heredoc or output redirection
Example fix
// before (content exceeds 1 MB):
await write_file({ filePath: 'data.json', content: hugeJsonString });
// after (split into chunks):
for (let i = 0; i < chunks.length; i++) {
await write_file({ filePath: `data-${i}.json`, content: chunks[i] });
} Defensive patterns
Strategy: validation
Validate before calling
import { MAX_FILE_SIZE } from './constants';
function isContentWithinLimit(content: string): boolean {
return Buffer.byteLength(content, 'utf-8') <= MAX_FILE_SIZE;
}
// Before calling write_file:
if (!isContentWithinLimit(content)) {
throw new Error(`Content is ${Buffer.byteLength(content, 'utf-8')} bytes, max is ${MAX_FILE_SIZE}. Split into multiple files.`);
} Type guard
function isContentTooLargeError(e: unknown): boolean {
return e instanceof Error && e.message.startsWith('Content too large:');
} Prevention
- Check Buffer.byteLength(content, 'utf-8') before writing — multi-byte characters count fully
- Split large content into multiple files under 1 MB each
- Use shell tools with heredoc or output redirection for files that exceed the limit
When it happens
Trigger: Writing a large file — a big data export, a large generated source file, a base64-encoded binary payload, or a file with extensive multi-byte character content.
Common situations: Agent generates a large file content string from data aggregation, tries to write a large base64 payload, or creates a large data structure.
Related errors
- File too large: ${stat.size} bytes (max ${MAX_FILE_SIZE} byt
- oldString not found in file: ${filePath}
- Access denied: "${excludedSegment}" is excluded from filesys
- File too large: ${stat.size} bytes (max ${MAX_FILE_SIZE} byt
- Unsupported binary file — only PNG, JPEG, GIF, WebP and PDF
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/1905553912e02e44.
Report an issue: GitHub.