toeverything/AFFiNE · error · BlockSuiteError

ParsingError

ParsingError

Error message

Unsupported file type

What it means

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.

Source

Thrown at blocksuite/affine/gfx/mindmap/src/toolbar/utils/import-mindmap.ts:28

  title?: string;
  layoutType?: 'left' | 'right';
};

export async function importMindmap(bound: Bound): Promise<MindMapNode> {
  const file = await openSingleFileWith('MindMap');

  if (!file) {
    throw new BlockSuiteError(ErrorCode.UserAbortError, 'Aborted by user');
  }

  let result;

  if (file.name.endsWith('.mm')) {
    result = await parseMmFile(file);
  } else if (file.name.endsWith('.opml') || file.name.endsWith('.xml')) {
    result = await parseOPMLFile(file);
  } else {
    throw new BlockSuiteError(ErrorCode.ParsingError, 'Unsupported file type');
  }

  if (result) {
    result.xywh = bound.serialize();
  }

  return result;
}

function readAsText(file: File) {
  return file.text();
}

type RawMmNode = {
  node?: {
    TEXT: string;
    POSITION: 'left' | 'right';
    children?: RawMmNode[];

View on GitHub (pinned to 26c515e050)

Solutions

  1. Restrict the file picker accept attribute to '.mm,.opml,.xml'.
  2. Show a user-facing message that only .mm/.opml/.xml are supported.
  3. Normalize the filename to lowercase before the extension check if case-insensitivity is desired.

Example fix

// before
openSingleFileWith('MindMap'); // user picks .xmind -> throws

// after
openSingleFileWith('MindMap', { accept: '.mm,.opml,.xml' });
Defensive patterns

Strategy: validation

Validate before calling

const ok = /\.(mm|opml|xml)$/i.test(file.name);
if (!ok) { alert('Only .mm, .opml, .xml files are supported'); return; }

Type guard

const isSupportedMindmapFile = (f: File): boolean => /\.(mm|opml|xml)$/i.test(f.name);

Prevention

When it happens

Trigger: User selects a file whose name does not end with .mm, .opml, or .xml (e.g. .xmind, .json, .png, .txt).

Common situations: User picks an unsupported mind-map format (XMind, Markdown, etc.); file lost its extension during download; case-sensitivity issues with extensions.

Related errors


AI-assisted analysis of toeverything/AFFiNE@26c515e050 (2026-08-12). Data as JSON: /api/errors/2495439a3e4c3ccd. Report an issue: GitHub.