{"record":{"id":"1905553912e02e44","repo":"n8n-io/n8n","slug":"content-too-large-bytesize-bytes-max-max-fi","errorCode":null,"errorMessage":"Content too large: ${byteSize} bytes (max ${MAX_FILE_SIZE} bytes).","messagePattern":"Content too large: (.+?) bytes \\(max (.+?) bytes\\)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/@n8n/computer-use/src/tools/filesystem/write-file.ts","lineNumber":31,"sourceCode":"});\n\nexport const writeFileTool: ToolDefinition<typeof inputSchema> = {\n\tname: 'write_file',\n\tdescription:\n\t\t'Create a new file with the given content. Overwrites if the file already exists. Content must not exceed 1 MB.',\n\tinputSchema,\n\tannotations: {},\n\tasync getAffectedResources({ filePath }, { dir }) {\n\t\treturn [\n\t\t\tawait buildFilesystemResource(dir, filePath, 'filesystemWrite', `Write file: ${filePath}`),\n\t\t];\n\t},\n\tasync execute({ filePath, content }, { dir }) {\n\t\tconst resolvedPath = await resolveSafePath(dir, filePath);\n\n\t\tconst byteSize = Buffer.byteLength(content, 'utf-8');\n\t\tif (byteSize > MAX_FILE_SIZE) {\n\t\t\tthrow new Error(`Content too large: ${byteSize} bytes (max ${MAX_FILE_SIZE} bytes).`);\n\t\t}\n\n\t\tawait fs.mkdir(path.dirname(resolvedPath), { recursive: true });\n\t\tawait fs.writeFile(resolvedPath, content, 'utf-8');\n\n\t\treturn formatCallToolResult({ path: filePath });\n\t},\n};\n","sourceCodeStart":13,"sourceCodeEnd":40,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/computer-use/src/tools/filesystem/write-file.ts#L13-L40","documentation":"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.","triggerScenarios":"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.","commonSituations":"Agent generates a large file content string from data aggregation, tries to write a large base64 payload, or creates a large data structure.","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"],"exampleFix":"// before (content exceeds 1 MB):\nawait write_file({ filePath: 'data.json', content: hugeJsonString });\n\n// after (split into chunks):\nfor (let i = 0; i < chunks.length; i++) {\n  await write_file({ filePath: `data-${i}.json`, content: chunks[i] });\n}","handlingStrategy":"validation","validationCode":"import { MAX_FILE_SIZE } from './constants';\n\nfunction isContentWithinLimit(content: string): boolean {\n  return Buffer.byteLength(content, 'utf-8') <= MAX_FILE_SIZE;\n}\n\n// Before calling write_file:\nif (!isContentWithinLimit(content)) {\n  throw new Error(`Content is ${Buffer.byteLength(content, 'utf-8')} bytes, max is ${MAX_FILE_SIZE}. Split into multiple files.`);\n}","typeGuard":"function isContentTooLargeError(e: unknown): boolean {\n  return e instanceof Error && e.message.startsWith('Content too large:');\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["filesystem","validation","computer-use"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}