{"record":{"id":"2495439a3e4c3ccd","repo":"toeverything/AFFiNE","slug":"parsingerror","errorCode":"ParsingError","errorMessage":"Unsupported file type","messagePattern":"Unsupported file type","errorType":"exception","errorClass":"BlockSuiteError","httpStatus":null,"severity":"error","filePath":"blocksuite/affine/gfx/mindmap/src/toolbar/utils/import-mindmap.ts","lineNumber":28,"sourceCode":"  title?: string;\n  layoutType?: 'left' | 'right';\n};\n\nexport async function importMindmap(bound: Bound): Promise<MindMapNode> {\n  const file = await openSingleFileWith('MindMap');\n\n  if (!file) {\n    throw new BlockSuiteError(ErrorCode.UserAbortError, 'Aborted by user');\n  }\n\n  let result;\n\n  if (file.name.endsWith('.mm')) {\n    result = await parseMmFile(file);\n  } else if (file.name.endsWith('.opml') || file.name.endsWith('.xml')) {\n    result = await parseOPMLFile(file);\n  } else {\n    throw new BlockSuiteError(ErrorCode.ParsingError, 'Unsupported file type');\n  }\n\n  if (result) {\n    result.xywh = bound.serialize();\n  }\n\n  return result;\n}\n\nfunction readAsText(file: File) {\n  return file.text();\n}\n\ntype RawMmNode = {\n  node?: {\n    TEXT: string;\n    POSITION: 'left' | 'right';\n    children?: RawMmNode[];","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/blocksuite/affine/gfx/mindmap/src/toolbar/utils/import-mindmap.ts#L10-L46","documentation":"After a file is chosen, importMindmap (import-mindmap.ts:21-29) only accepts FreeMind .mm files and .opml/.xml outlines; any other extension throws ParsingError 'Unsupported file type'. The check is by filename extension only, so a mismatched payload renamed to .mm will pass this check and fail later in parsing.","triggerScenarios":"User selects .xlsx/.md/.json or an extension-less export in the mindmap import picker; browsers/platforms that do not enforce the accept filter; files with trailing spaces or unusual case in the extension (endsWith is case-sensitive, so '.MM' also throws).","commonSituations":"File picker accept filter missing or ignored by the OS dialog; users trying to import OPML variants with uncommon extensions; case-sensitive extension mismatch on macOS/Windows exports.","solutions":["Pre-check the extension before calling importMindmap and show a friendly 'Supported: .mm, .opml, .xml' message","Set the picker's accept filter to .mm,.opml,.xml if the file-dialog API supports it","Normalize with file.name.toLowerCase().endsWith(...) before dispatching to a parser"],"exampleFix":"// before\nconst mindmap = await importMindmap(bound); // picks notes.txt -> ParsingError\n\n// after\nconst name = file.name.toLowerCase();\nif (!name.endsWith('.mm') && !name.endsWith('.opml') && !name.endsWith('.xml')) {\n  toast('Unsupported file type. Use .mm, .opml or .xml.');\n  return;\n}","handlingStrategy":"validation","validationCode":"const SUPPORTED = ['.mm', '.opml', '.xml'] as const;\n\nconst isSupportedMindmapFile = (file: File): boolean => {\n  const name = file.name.toLowerCase();\n  return SUPPORTED.some(ext => name.endsWith(ext));\n};\n\nif (!isSupportedMindmapFile(file)) {\n  toast('Unsupported file type. Use .mm, .opml or .xml.');\n  return;\n}","typeGuard":"function isSupportedMindmapFile(file: File): boolean {\n  const n = file.name.toLowerCase();\n  return n.endsWith('.mm') || n.endsWith('.opml') || n.endsWith('.xml');\n}","tryCatchPattern":"try {\n  const mindmap = await importMindmap(bound);\n} catch (e) {\n  if (e instanceof BlockSuiteError && e.code === BlockSuiteError.ErrorCode.ParsingError) {\n    toast('Unsupported file type. Use .mm, .opml or .xml.');\n    return;\n  }\n  throw e;\n}","preventionTips":["Set the file picker accept filter to .mm,.opml,.xml where the dialog API allows","Check extensions case-insensitively before calling importMindmap","Tell users the supported formats in the import UI up front"],"tags":["mindmap","import","file-type","validation"],"backgroundTag":"unsupported-file-format","analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}