{"record":{"id":"acdc0017f29644aa","repo":"hcengineering/platform","slug":"db-page-metadata-not-found-docmeta-name","errorCode":null,"errorMessage":"DB page metadata not found: ${docMeta.name}","messagePattern":"DB page metadata not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/importer/src/notion/notion.ts","lineNumber":381,"sourceCode":"\nasync function importDBAttachment (\n  client: TxOperations,\n  fileUploader: FileUploader,\n  data: Buffer,\n  docMeta: DocumentMetadata,\n  space: Ref<Teamspace>,\n  parentMeta?: DocumentMetadata,\n  documentMetaMap?: Map<string, DocumentMetadata>\n): Promise<void> {\n  const matched = docMeta.notionId.match(/([\\d\\w]*)_all$/)\n  if (matched == null || matched.length < 2) {\n    throw new Error('DB file not found: ' + docMeta.name)\n  }\n\n  const originalNotionId = matched[1]\n  const dbPage = documentMetaMap?.get(originalNotionId)\n  if (dbPage === undefined) {\n    throw new Error('DB page metadata not found: ' + docMeta.name)\n  }\n\n  const attachment: DocumentMetadata = {\n    id: docMeta.id,\n    notionParentId: dbPage.id,\n    name: docMeta.name,\n    notionId: docMeta.notionId,\n    mimeType: docMeta.mimeType,\n    size: docMeta.size\n  }\n  await importAttachment(client, fileUploader, data, attachment, space, dbPage)\n}\n\nasync function importAttachment (\n  client: TxOperations,\n  fileUploader: FileUploader,\n  data: Buffer,\n  docMeta: DocumentMetadata,","sourceCodeStart":363,"sourceCodeEnd":399,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/packages/importer/src/notion/notion.ts#L363-L399","documentation":"After extracting originalNotionId from the '<id>_all' attachment name, importDBAttachment looks up the parent database page in documentMetaMap. If the map is undefined or lacks that id, the attachment's owning database page metadata is missing and the attachment cannot be linked, so the import throws.","triggerScenarios":"importDBAttachment called without a documentMetaMap argument, or the map does not contain the database page whose notionId matches the attachment's originalNotionId — e.g. the DB page was excluded from the export or metadata collection failed for it.","commonSituations":"Partial Notion exports missing the parent database; calling importDBAttachment programmatically without passing documentMetaMap; out-of-order import where DB page metadata was not collected before attachments are processed.","solutions":["Always pass the fully populated documentMetaMap to importDBAttachment","Ensure the parent database page is included in the export and its metadata collected before attachments","Verify documentMetaMap has a key matching matched[1] (originalNotionId) before importing attachments","Re-export the workspace including the database that owns the attachment"],"exampleFix":"// before\nawait importDBAttachment(client, fileUploader, data, docMeta, space, parentMeta)\n// after\nawait importDBAttachment(client, fileUploader, data, docMeta, space, parentMeta, documentMetaMap)","handlingStrategy":"validation","validationCode":"const matched = docMeta.notionId.match(/([\\d\\w]*)_all$/)\nconst originalNotionId = matched?.[1]\nif (originalNotionId === undefined || !documentMetaMap?.has(originalNotionId)) {\n  throw new Error('Parent DB page missing from metadata map for: ' + docMeta.name)\n}\nawait importDBAttachment(client, fileUploader, data, docMeta, space, parentMeta, documentMetaMap)","typeGuard":"function hasParentDbPage(docMeta, documentMetaMap) {\n  const m = docMeta.notionId.match(/([\\d\\w]*)_all$/)\n  return m != null && documentMetaMap != null && documentMetaMap.has(m[1])\n}","tryCatchPattern":"try {\n  await importDBAttachment(...)\n} catch (err) {\n  if (err.message.startsWith('DB page metadata not found: ')) {\n    console.warn('Parent DB page missing, deferring attachment:', docMeta.name)\n    deferredAttachments.push(docMeta)\n    return\n  }\n  throw err\n}","preventionTips":["Always pass a populated documentMetaMap to importDBAttachment","Include all parent databases in the Notion export","Collect page metadata before processing attachments","Check map.has(originalNotionId) before importing attachments"],"tags":["notion","import","missing-metadata"],"backgroundTag":"missing-parent-metadata","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}