n8n-io/n8n · warning · Error
Unsupported binary file — only PNG, JPEG, GIF, WebP and PDF
Error message
Unsupported binary file — only PNG, JPEG, GIF, WebP and PDF are readable
What it means
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.
Source
Thrown at packages/@n8n/computer-use/src/tools/filesystem/read-file.ts:56
const resolvedPath = await resolveReadablePath(dir, filePath);
const stat = await fs.stat(resolvedPath);
if (stat.size > MAX_FILE_SIZE) {
throw new Error(
`File too large: ${stat.size} bytes (max ${MAX_FILE_SIZE} bytes). Use searchFiles for specific content.`,
);
}
const fileContent = await fs.readFile(resolvedPath);
const buffer = Buffer.isBuffer(fileContent) ? fileContent : Buffer.from(fileContent);
const binaryType = detectSupportedBinaryFile(filePath);
if (binaryType) {
return buildBinaryResult(resolvedPath, buffer, binaryType);
}
if (isLikelyBinaryContent(buffer)) {
throw new Error('Unsupported binary file — only PNG, JPEG, GIF, WebP and PDF are readable');
}
return buildTextResult(filePath, buffer.toString('utf-8'), startLine, maxLines);
},
};
function buildTextResult(
filePath: string,
content: string,
startLine: number | undefined,
maxLines: number | undefined,
): CallToolResult {
const allLines = content.split('\n');
const lines = maxLines ?? DEFAULT_MAX_LINES;
const start = startLine ?? 1;
const startIndex = Math.max(0, start - 1);
const slicedLines = allLines.slice(startIndex, startIndex + lines);
const truncated = allLines.length > startIndex + lines;View on GitHub (pinned to 5ac6606e81)
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
Defensive patterns
Strategy: validation
Validate before calling
import { isLikelyBinaryContent } from './fs-utils';
const SUPPORTED_BINARY_EXTENSIONS = new Set(['.png', '.jpg', '.jpeg', '.gif', '.webp', '.pdf']);
async function isReadableTextOrSupportedBinary(filePath: string): Promise<boolean> {
const ext = filePath.toLowerCase().match(/\.[^.]+$/)?.[0] ?? '';
if (SUPPORTED_BINARY_EXTENSIONS.has(ext)) return true;
const buffer = await fs.readFile(filePath);
return !isLikelyBinaryContent(buffer);
} Type guard
function isUnsupportedBinaryError(e: unknown): boolean {
return e instanceof Error && e.message.startsWith('Unsupported binary file');
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Agent tries to read a compiled binary, a compressed archive, an Office document, or a font file.
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
- Pattern "${pattern}" escapes the base directory
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/d85b6b07500cbe28.
Report an issue: GitHub.