{"record":{"id":"38b6f0858507542f","repo":"n8n-io/n8n","slug":"unsupported-format-for-attachment-filename","errorCode":null,"errorMessage":"Unsupported format for \"${attachment.fileName}\" (${attachment.mimeType}). Supported: csv, tsv, json","messagePattern":"Unsupported format for \"(.+?)\" \\((.+?)\\)\\. Supported: csv, tsv, json","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/@n8n/instance-ai/src/parsers/structured-file-parser.ts","lineNumber":386,"sourceCode":"\tattachmentIndex: number,\n\tinput: ParseFileInput,\n): ParseFileOutput {\n\t// Decode base64\n\tlet decoded: Buffer;\n\ttry {\n\t\tdecoded = Buffer.from(attachment.data, 'base64');\n\t} catch {\n\t\tthrow new Error('Failed to decode base64 attachment data');\n\t}\n\n\tif (decoded.length > MAX_DECODED_SIZE_BYTES) {\n\t\tthrow new Error(formatSizeLimitMessage(decoded.length));\n\t}\n\n\tconst content = decoded.toString('utf-8');\n\tconst format = detectFormat(attachment.fileName, attachment.mimeType, input.format);\n\tif (!format || !isLegacyTabularFormat(format)) {\n\t\tthrow new Error(\n\t\t\t`Unsupported format for \"${attachment.fileName}\" (${attachment.mimeType}). Supported: csv, tsv, json`,\n\t\t);\n\t}\n\n\tconst hasHeader = input.hasHeader ?? true;\n\tconst startRow = input.startRow ?? 0;\n\tconst maxRows = Math.min(input.maxRows ?? DEFAULT_MAX_ROWS, MAX_ROWS_PER_CALL);\n\tconst warnings: string[] = [];\n\n\tlet columns: ColumnMeta[];\n\tlet paginatedRows: Array<Record<string, CellValue>>;\n\tlet totalRows: number;\n\n\tif (format === 'json') {\n\t\tconst { rawHeaders, allRows } = parseJson(content);\n\n\t\tif (rawHeaders.length > MAX_COLUMNS) {\n\t\t\tthrow new Error(`Too many columns: ${rawHeaders.length} (max ${MAX_COLUMNS})`);","sourceCodeStart":368,"sourceCodeEnd":404,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/instance-ai/src/parsers/structured-file-parser.ts#L368-L404","documentation":"Thrown by parseStructuredFile when detectFormat returns a falsy value or returns a format that is not a legacy tabular format (csv/tsv/json) — see isLegacyTabularFormat at structured-file-parser.ts:66. parseStructuredFile only handles csv, tsv, and json; xlsx/html/pdf/docx/markdown/text each have dedicated extractors and must not be routed here.","triggerScenarios":"Calling parseStructuredFile with a format hint of 'xlsx', 'html', 'pdf', 'docx', 'text', or 'markdown'; or attaching a file whose name has no recognized extension and whose mimeType is not in MIME_TO_FORMAT. Also when input.format is set to an unsupported value explicitly.","commonSituations":"A caller routes an .xlsx through parseStructuredFile instead of extractXlsxAsRows; a fileName like 'data.dat' with an arbitrary mimeType; a format string typo; a new format added to SupportedFormat but not to isLegacyTabularFormat.","solutions":["Route xlsx to extractXlsxAsRows and html/pdf/docx to their dedicated parsers instead of parseStructuredFile.","Set a correct mimeType on AttachmentInfo (e.g. text/csv, application/json).","Rename the file to a recognized extension (.csv/.tsv/.json) so detectFormat can infer it.","Pass input.format explicitly as 'csv' | 'tsv' | 'json' when the filename is ambiguous."],"exampleFix":"// before: parseStructuredFile({ fileName: 'data.xlsx', mimeType: 'application/vnd...sheet', data }, 0, { format: 'xlsx' })\n// after:  await extractXlsxAsRows({ fileName: 'data.xlsx', mimeType: 'application/vnd...sheet', data }, 0, input)","handlingStrategy":"validation","validationCode":"const SUPPORTED = new Set(['csv','tsv','json']);\nfunction routeAttachment(mimeType: string, fileName: string) {\n  const ext = fileName.split('.').pop()?.toLowerCase();\n  if (mimeType === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || ext === 'xlsx') return 'xlsx';\n  // ... text-like formats\n  const fmt = SUPPORTED.has(ext ?? '') ? ext : undefined;\n  if (!fmt) throw new Error(`Route to parseStructuredFile only for csv/tsv/json; got ${mimeType}/${fileName}`);\n  return fmt;\n}","typeGuard":"function isLegacyTabularFormat(f: unknown): f is 'csv' | 'tsv' | 'json' {\n  return f === 'csv' || f === 'tsv' || f === 'json';\n}","tryCatchPattern":"try { return parseStructuredFile(attachment, idx, input); }\ncatch (e) {\n  if (e instanceof Error && e.message.startsWith('Unsupported format for')) {\n    // dispatch to the format-specific extractor (xlsx/html/pdf/docx) instead\n  }\n  throw e;\n}","preventionTips":["Route by mimeType to the correct extractor before calling parseStructuredFile.","Set explicit input.format when the filename is ambiguous.","Keep MIME_TO_FORMAT and isLegacyTabularFormat in sync when adding formats."],"tags":["format-detection","attachment-parsing","routing","validation"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}