{"record":{"id":"f7d492cd63e98512","repo":"toeverything/AFFiNE","slug":"pdfadapter-does-not-support-importing-slices-from","errorCode":null,"errorMessage":"PdfAdapter does not support importing slices from PDF.","messagePattern":"PdfAdapter does not support importing slices from PDF\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"blocksuite/affine/shared/src/adapters/pdf/pdf.ts","lineNumber":156,"sourceCode":"      },\n      assetsIds: [],\n    };\n  }\n\n  toBlockSnapshot(\n    _payload: ToBlockSnapshotPayload<PdfAdapterFile>\n  ): BlockSnapshot {\n    throw new Error('PdfAdapter does not support importing blocks from PDF.');\n  }\n\n  toDocSnapshot(_payload: ToDocSnapshotPayload<PdfAdapterFile>): DocSnapshot {\n    throw new Error('PdfAdapter does not support importing docs from PDF.');\n  }\n\n  toSliceSnapshot(\n    _payload: ToSliceSnapshotPayload<PdfAdapterFile>\n  ): SliceSnapshot | null {\n    throw new Error('PdfAdapter does not support importing slices from PDF.');\n  }\n\n  /**\n   * Get the pdfmake document definition (for testing purposes)\n   */\n  async getDocDefinition(\n    blocks: BlockSnapshot[],\n    title?: string,\n    assets?: FromDocSnapshotPayload['assets']\n  ): Promise<TDocumentDefinitions> {\n    const content = await this._buildContent(blocks, assets);\n    return this._createDocDefinition(title, content);\n  }\n\n  private async _buildContent(\n    blocks: BlockSnapshot[],\n    assets?: FromDocSnapshotPayload['assets']\n  ): Promise<Content[]> {","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/blocksuite/affine/shared/src/adapters/pdf/pdf.ts#L138-L174","documentation":"toSliceSnapshot on PdfAdapter is an intentionally unimplemented adapter method: PDF exports cannot be turned into slice snapshots, so any attempt to import a slice from a PDF hits this hard rejection. It fires when a caller passes a ToSliceSnapshotPayload<PdfAdapterFile> to this adapter.","triggerScenarios":"Thrown at blocksuite/affine/shared/src/adapters/pdf/pdf.ts:156 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Slice-level PDF import is not supported. Import the content at block or doc level using another adapter, or extract the PDF content externally first.","Add a capability check before calling toSliceSnapshot on PdfAdapter and gracefully degrade to a 'not supported' notification."],"exampleFix":"try {\n  await pdfAdapter.toSliceSnapshot(payload);\n} catch {\n  // PDF slice import unsupported — extract content with pdf.js instead\n  const text = await extractPdfText(file);\n  return markdownAdapter.toSliceSnapshot({ file: text, assets, workspaceId, pageId });\n}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}