hcengineering/platform · error · Error
DB file not found: ${docMeta.name}
Error message
DB file not found: ${docMeta.name} What it means
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.
Source
Thrown at packages/importer/src/notion/notion.ts:375
mimeType: docMeta.mimeType,
size: docMeta.size
}
await importAttachment(client, fileUploader, data, attachment, space, dbPage)
}
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)
}View on GitHub (pinned to 63e28dc964)
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
Example fix
// before
await importDBAttachment(client, fileUploader, data, anyDocMeta, space, parentMeta, documentMetaMap)
// after
if (/([\d\w]*)_all$/.test(anyDocMeta.notionId)) {
await importDBAttachment(client, fileUploader, data, anyDocMeta, space, parentMeta, documentMetaMap)
} else {
await importAttachment(client, fileUploader, data, anyDocMeta, space, parentMeta)
} Defensive patterns
Strategy: validation
Validate before calling
const ALL_SUFFIX = /([\d\w]*)_all$/
if (!ALL_SUFFIX.test(docMeta.notionId)) {
throw new Error('Not a DB attachment (missing _all suffix): ' + docMeta.name)
}
await importDBAttachment(client, fileUploader, data, docMeta, space, parentMeta, documentMetaMap) Type guard
function isDbAttachment(docMeta) {
return typeof docMeta.notionId === 'string' && /([\d\w]*)_all$/.test(docMeta.notionId)
} Try / catch
try {
await importDBAttachment(...)
} catch (err) {
if (err.message.startsWith('DB file not found: ')) {
console.warn('Entry is not a DB attachment, falling back to plain attachment:', docMeta.name)
await importAttachment(client, fileUploader, data, docMeta, space, parentMeta)
return
}
throw err
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Teamspace not found for document: ${docMeta.name}
- Importing folder entry is not supported: ${fileMeta.fileName
- DB page metadata not found: ${docMeta.name}
- Cannot import attachment without parent doc: ${docMeta.id}
- Linked page not found (outside of this import):
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/2885f1d7533d1155.
Report an issue: GitHub.