{"record":{"id":"2495439a3e4c3ccd","repo":"toeverything/AFFiNE","slug":"parsingerror","errorCode":"ParsingError","errorMessage":"Unsupported file type","messagePattern":"Unsupported file type","errorType":"error_code","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/26c515e050211269e911f7d9cfe162a26c83ed98/blocksuite/affine/gfx/mindmap/src/toolbar/utils/import-mindmap.ts#L10-L46","documentation":"importMindmap() dispatches on the file extension: .mm routes to parseMmFile, .opml/.xml to parseOPMLFile. Any other extension throws ParsingError('Unsupported file type'). The importer only accepts FreeMind (.mm) and OPML (.opml/.xml) formats.","triggerScenarios":"User selects a file whose name does not end with .mm, .opml, or .xml (e.g. .xmind, .json, .png, .txt).","commonSituations":"User picks an unsupported mind-map format (XMind, Markdown, etc.); file lost its extension during download; case-sensitivity issues with extensions.","solutions":["Restrict the file picker accept attribute to '.mm,.opml,.xml'.","Show a user-facing message that only .mm/.opml/.xml are supported.","Normalize the filename to lowercase before the extension check if case-insensitivity is desired."],"exampleFix":"// before\nopenSingleFileWith('MindMap'); // user picks .xmind -> throws\n\n// after\nopenSingleFileWith('MindMap', { accept: '.mm,.opml,.xml' });","handlingStrategy":"validation","validationCode":"const ok = /\\.(mm|opml|xml)$/i.test(file.name);\nif (!ok) { alert('Only .mm, .opml, .xml files are supported'); return; }","typeGuard":"const isSupportedMindmapFile = (f: File): boolean => /\\.(mm|opml|xml)$/i.test(f.name);","tryCatchPattern":null,"preventionTips":["Set the file picker accept to '.mm,.opml,.xml'","Show supported formats in the UI before the picker opens"],"tags":["mindmap","import","file-type","parsing"],"backgroundTag":null,"analyzedSha":"26c515e050211269e911f7d9cfe162a26c83ed98","analyzedAt":"2026-08-12T13:15:16.447Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}