{"record":{"id":"d85b6b07500cbe28","repo":"n8n-io/n8n","slug":"unsupported-binary-file-only-png-jpeg-gif-web","errorCode":null,"errorMessage":"Unsupported binary file — only PNG, JPEG, GIF, WebP and PDF are readable","messagePattern":"Unsupported binary file — only PNG, JPEG, GIF, WebP and PDF are readable","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/@n8n/computer-use/src/tools/filesystem/read-file.ts","lineNumber":56,"sourceCode":"\t\tconst resolvedPath = await resolveReadablePath(dir, filePath);\n\n\t\tconst stat = await fs.stat(resolvedPath);\n\t\tif (stat.size > MAX_FILE_SIZE) {\n\t\t\tthrow new Error(\n\t\t\t\t`File too large: ${stat.size} bytes (max ${MAX_FILE_SIZE} bytes). Use searchFiles for specific content.`,\n\t\t\t);\n\t\t}\n\n\t\tconst fileContent = await fs.readFile(resolvedPath);\n\t\tconst buffer = Buffer.isBuffer(fileContent) ? fileContent : Buffer.from(fileContent);\n\n\t\tconst binaryType = detectSupportedBinaryFile(filePath);\n\t\tif (binaryType) {\n\t\t\treturn buildBinaryResult(resolvedPath, buffer, binaryType);\n\t\t}\n\n\t\tif (isLikelyBinaryContent(buffer)) {\n\t\t\tthrow new Error('Unsupported binary file — only PNG, JPEG, GIF, WebP and PDF are readable');\n\t\t}\n\n\t\treturn buildTextResult(filePath, buffer.toString('utf-8'), startLine, maxLines);\n\t},\n};\n\nfunction buildTextResult(\n\tfilePath: string,\n\tcontent: string,\n\tstartLine: number | undefined,\n\tmaxLines: number | undefined,\n): CallToolResult {\n\tconst allLines = content.split('\\n');\n\tconst lines = maxLines ?? DEFAULT_MAX_LINES;\n\tconst start = startLine ?? 1;\n\tconst startIndex = Math.max(0, start - 1);\n\tconst slicedLines = allLines.slice(startIndex, startIndex + lines);\n\tconst truncated = allLines.length > startIndex + lines;","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/computer-use/src/tools/filesystem/read-file.ts#L38-L74","documentation":"Thrown by read_file when the file content is detected as binary (via isLikelyBinaryContent — presence of null bytes or non-decodable UTF-8) AND the file extension is not one of the supported binary types (PNG, JPEG, GIF, WebP, PDF — detected by detectSupportedBinaryFile). Supported image and PDF files are returned as binary results; unsupported binary formats are rejected.","triggerScenarios":"Reading a .exe, .zip, .tar, .gz, .docx, .xlsx, .so, .class, .woff, or any other binary file that is not PNG/JPEG/GIF/WebP/PDF. The null-byte or non-UTF-8 content triggers isLikelyBinaryContent, and detectSupportedBinaryFile returns null for the extension.","commonSituations":"Agent tries to read a compiled binary, a compressed archive, an Office document, or a font file.","solutions":["Convert the file to a supported image format (PNG/JPEG/GIF/WebP) or PDF before reading","Use shell tools to extract text content (e.g. unzip + read the inner XML for .docx)","Use a dedicated parser or library for the specific binary format"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { isLikelyBinaryContent } from './fs-utils';\n\nconst SUPPORTED_BINARY_EXTENSIONS = new Set(['.png', '.jpg', '.jpeg', '.gif', '.webp', '.pdf']);\n\nasync function isReadableTextOrSupportedBinary(filePath: string): Promise<boolean> {\n  const ext = filePath.toLowerCase().match(/\\.[^.]+$/)?.[0] ?? '';\n  if (SUPPORTED_BINARY_EXTENSIONS.has(ext)) return true;\n  const buffer = await fs.readFile(filePath);\n  return !isLikelyBinaryContent(buffer);\n}","typeGuard":"function isUnsupportedBinaryError(e: unknown): boolean {\n  return e instanceof Error && e.message.startsWith('Unsupported binary file');\n}","tryCatchPattern":null,"preventionTips":["Check the file extension against supported types (PNG, JPEG, GIF, WebP, PDF) before reading","Convert binary files to supported formats before attempting to read them","Use shell tools to extract text content from unsupported binary formats"],"tags":["filesystem","validation","binary","computer-use"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}