{"record":{"id":"2885f1d7533d1155","repo":"hcengineering/platform","slug":"db-file-not-found-docmeta-name","errorCode":null,"errorMessage":"DB file not found: ${docMeta.name}","messagePattern":"DB file not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/importer/src/notion/notion.ts","lineNumber":375,"sourceCode":"    mimeType: docMeta.mimeType,\n    size: docMeta.size\n  }\n\n  await importAttachment(client, fileUploader, data, attachment, space, dbPage)\n}\n\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}","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/packages/importer/src/notion/notion.ts#L357-L393","documentation":"Database attachments in a Notion export are named with an '<originalNotionId>_all' suffix pattern. importDBAttachment parses docMeta.notionId with the regex /([\\d\\w]*)_all$/ to recover the source database page id; if the id does not end with '_all', the entry is not a recognized DB attachment and the import cannot locate its owning database.","triggerScenarios":"importDBAttachment receives a docMeta whose notionId lacks the '_all' suffix — e.g. a regular page or file misrouted into the DB-attachment import path, or a renamed attachment file in the export zip.","commonSituations":"Manually renamed files inside the Notion export archive breaking the '<id>_all' naming convention; passing non-database attachments to importDBAttachment; exporter version changes altering the attachment naming scheme.","solutions":["Keep exported attachment filenames untouched so the '<notionId>_all' pattern is preserved","Route only DB-derived attachments (ids ending in _all) to importDBAttachment; send others to importAttachment","Log and inspect docMeta.notionId for entries failing the regex to find which files were renamed","Re-export the archive if naming was altered"],"exampleFix":"// before\nawait importDBAttachment(client, fileUploader, data, anyDocMeta, space, parentMeta, documentMetaMap)\n// after\nif (/([\\d\\w]*)_all$/.test(anyDocMeta.notionId)) {\n  await importDBAttachment(client, fileUploader, data, anyDocMeta, space, parentMeta, documentMetaMap)\n} else {\n  await importAttachment(client, fileUploader, data, anyDocMeta, space, parentMeta)\n}","handlingStrategy":"validation","validationCode":"const ALL_SUFFIX = /([\\d\\w]*)_all$/\nif (!ALL_SUFFIX.test(docMeta.notionId)) {\n  throw new Error('Not a DB attachment (missing _all suffix): ' + docMeta.name)\n}\nawait importDBAttachment(client, fileUploader, data, docMeta, space, parentMeta, documentMetaMap)","typeGuard":"function isDbAttachment(docMeta) {\n  return typeof docMeta.notionId === 'string' && /([\\d\\w]*)_all$/.test(docMeta.notionId)\n}","tryCatchPattern":"try {\n  await importDBAttachment(...)\n} catch (err) {\n  if (err.message.startsWith('DB file not found: ')) {\n    console.warn('Entry is not a DB attachment, falling back to plain attachment:', docMeta.name)\n    await importAttachment(client, fileUploader, data, docMeta, space, parentMeta)\n    return\n  }\n  throw err\n}","preventionTips":["Never rename files in the Notion export archive","Only route ids matching '<id>_all' to importDBAttachment","Verify exporter version produces the expected attachment naming convention","Unit-test the id regex against real export filenames"],"tags":["notion","import","naming-convention"],"backgroundTag":"id-pattern-mismatch","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}