toeverything/AFFiNE · warning · BlockSuiteError

TransformerNotImplementedError

TransformerNotImplementedError

Error message

NotionHtmlAdapter.fromBlockSnapshot is not implemented

What it means

NotionHtmlAdapter (affine/shared/src/adapters/notion-html/notion-html.ts:144-149) is an import-only adapter: it implements toBlockSnapshot (Notion HTML -> block snapshot). The export direction fromBlockSnapshot is deliberately unimplemented and throws TransformerNotImplementedError whenever called.

Source

Thrown at blocksuite/affine/shared/src/adapters/notion-html/notion-html.ts:141

    const notionHtmlInlineToDeltaMatchers = Array.from(
      provider.getAll(NotionHtmlASTToDeltaMatcherIdentifier).values()
    );
    this.blockMatchers = blockMatchers;
    this.deltaConverter = new NotionHtmlDeltaConverter(
      job.adapterConfigs,
      [],
      notionHtmlInlineToDeltaMatchers
    );
  }

  private _htmlToAst(notionHtml: NotionHtml) {
    return unified().use(rehypeParse).parse(notionHtml);
  }

  override fromBlockSnapshot(
    _payload: FromBlockSnapshotPayload
  ): Promise<FromBlockSnapshotResult<NotionHtml>> {
    throw new BlockSuiteError(
      ErrorCode.TransformerNotImplementedError,
      'NotionHtmlAdapter.fromBlockSnapshot is not implemented'
    );
  }

  override fromDocSnapshot(
    _payload: FromDocSnapshotPayload
  ): Promise<FromDocSnapshotResult<NotionHtml>> {
    throw new BlockSuiteError(
      ErrorCode.TransformerNotImplementedError,
      'NotionHtmlAdapter.fromDocSnapshot is not implemented'
    );
  }

  override fromSliceSnapshot(
    _payload: FromSliceSnapshotPayload
  ): Promise<FromSliceSnapshotResult<NotionHtml>> {
    throw new BlockSuiteError(

View on GitHub (pinned to b4c8548c09)

Solutions

  1. Do not use NotionHtmlAdapter for export; use an adapter that implements fromBlockSnapshot (e.g. MarkdownAdapter/HtmlAdapter) for doc->output
  2. Catch TransformerNotImplementedError in generic adapter loops and skip the adapter
  3. Check adapter capabilities before calling (this adapter only supports toBlockSnapshot)

Example fix

// before
const html = await adapter.fromBlockSnapshot({ snapshot, assets }); // throws

// after
if (adapter instanceof NotionHtmlAdapter) {
  throw new Error('Export to Notion HTML is not supported');
}
const md = await markdownAdapter.fromBlockSnapshot({ snapshot, assets });
Defensive patterns

Strategy: try-catch

Validate before calling

import { NotionHtmlAdapter } from '@blocksuite/affine/shared/adapters/notion-html';

// only use the supported direction
const supportsFromBlockSnapshot = (adapter: unknown): boolean =>
  !(adapter instanceof NotionHtmlAdapter); // this adapter is toBlockSnapshot-only

Type guard

function isImportOnlyAdapter(adapter: Adapter): boolean {
  return adapter instanceof NotionHtmlAdapter;
}

Try / catch

import { BlockSuiteError } from '@blocksuite/global/exceptions';

try {
  const output = await adapter.fromBlockSnapshot(payload);
} catch (e) {
  if (e instanceof BlockSuiteError && e.code === BlockSuiteError.ErrorCode.TransformerNotImplementedError) {
    // adapter cannot export; skip it or pick another adapter
    continue;
  }
  throw e;
}

Prevention

When it happens

Trigger: Running a block-snapshot -> Notion HTML export (e.g. Transformer job that iterates adapters and calls fromBlockSnapshot on every registered adapter); explicitly invoking NotionHtmlAdapter.get().fromBlockSnapshot(payload).

Common situations: Copy/paste or export pipelines that query all registered adapters generically; a user's clipboard containing Notion HTML triggers toBlockSnapshot (fine), but an export-to-Notion-HTML feature would hit this; code assuming every Adapter implements all six methods.

Related errors


AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18). Data as JSON: /api/errors/02552b150ce4934e. Report an issue: GitHub.