hcengineering/platform · error · Error

DB page metadata not found: ${docMeta.name}

Error message

DB page metadata not found: ${docMeta.name}

What it means

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.

Source

Thrown at packages/importer/src/notion/notion.ts:381

async function importDBAttachment (
  client: TxOperations,
  fileUploader: FileUploader,
  data: Buffer,
  docMeta: DocumentMetadata,
  space: Ref<Teamspace>,
  parentMeta?: DocumentMetadata,
  documentMetaMap?: Map<string, DocumentMetadata>
): Promise<void> {
  const matched = docMeta.notionId.match(/([\d\w]*)_all$/)
  if (matched == null || matched.length < 2) {
    throw new Error('DB file not found: ' + docMeta.name)
  }

  const originalNotionId = matched[1]
  const dbPage = documentMetaMap?.get(originalNotionId)
  if (dbPage === undefined) {
    throw new Error('DB page metadata not found: ' + docMeta.name)
  }

  const attachment: DocumentMetadata = {
    id: docMeta.id,
    notionParentId: dbPage.id,
    name: docMeta.name,
    notionId: docMeta.notionId,
    mimeType: docMeta.mimeType,
    size: docMeta.size
  }
  await importAttachment(client, fileUploader, data, attachment, space, dbPage)
}

async function importAttachment (
  client: TxOperations,
  fileUploader: FileUploader,
  data: Buffer,
  docMeta: DocumentMetadata,

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Always pass the fully populated documentMetaMap to importDBAttachment
  2. Ensure the parent database page is included in the export and its metadata collected before attachments
  3. Verify documentMetaMap has a key matching matched[1] (originalNotionId) before importing attachments
  4. Re-export the workspace including the database that owns the attachment

Example fix

// before
await importDBAttachment(client, fileUploader, data, docMeta, space, parentMeta)
// after
await importDBAttachment(client, fileUploader, data, docMeta, space, parentMeta, documentMetaMap)
Defensive patterns

Strategy: validation

Validate before calling

const matched = docMeta.notionId.match(/([\d\w]*)_all$/)
const originalNotionId = matched?.[1]
if (originalNotionId === undefined || !documentMetaMap?.has(originalNotionId)) {
  throw new Error('Parent DB page missing from metadata map for: ' + docMeta.name)
}
await importDBAttachment(client, fileUploader, data, docMeta, space, parentMeta, documentMetaMap)

Type guard

function hasParentDbPage(docMeta, documentMetaMap) {
  const m = docMeta.notionId.match(/([\d\w]*)_all$/)
  return m != null && documentMetaMap != null && documentMetaMap.has(m[1])
}

Try / catch

try {
  await importDBAttachment(...)
} catch (err) {
  if (err.message.startsWith('DB page metadata not found: ')) {
    console.warn('Parent DB page missing, deferring attachment:', docMeta.name)
    deferredAttachments.push(docMeta)
    return
  }
  throw err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29). Data as JSON: /api/errors/acdc0017f29644aa. Report an issue: GitHub.