hcengineering/platform · error · Error
Teamspace not found for document: ${docMeta.name}
Error message
Teamspace not found for document: ${docMeta.name} What it means
During a Notion import, importFiles iterates every non-folder entry and resolves the Notion teamspace (workspace sub-root) the entry belongs to via spaceIdMap, keyed by docMeta.notionSubRootId. If the map lookup returns undefined or false, the importer cannot determine which teamspace to import the document into, so it aborts with this error. This indicates the export/archive contains a document whose parent teamspace was not captured during metadata collection.
Source
Thrown at packages/importer/src/notion/notion.ts:231
}
}
}
async function importFiles (
client: TxOperations,
fileUploader: FileUploader,
fileMetaMap: Map<string, FileMetadata>,
documentMetaMap: Map<string, DocumentMetadata>,
spaceIdMap: Map<string, Ref<Teamspace>>
): Promise<void> {
for (const [notionId, fileMeta] of fileMetaMap) {
if (!fileMeta.isFolder) {
const docMeta = documentMetaMap.get(notionId)
if (docMeta === undefined) throw new Error('Cannot find metadata for entry: ' + fileMeta.fileName)
const spaceId = docMeta.notionSubRootId !== undefined && spaceIdMap.get(docMeta.notionSubRootId)
if (spaceId === undefined || spaceId === false) {
throw new Error('Teamspace not found for document: ' + docMeta.name)
}
await importFile(client, fileUploader, fileMeta, docMeta, spaceId, documentMetaMap)
}
}
}
async function importFile (
client: TxOperations,
fileUploader: FileUploader,
fileMeta: FileMetadata,
docMeta: DocumentMetadata,
spaceId: Ref<Teamspace>,
documentMetaMap: Map<string, DocumentMetadata>
): Promise<void> {
await new Promise<void>((resolve, reject) => {
if (fileMeta.isFolder) throw new Error('Importing folder entry is not supported: ' + fileMeta.fileName)
View on GitHub (pinned to 63e28dc964)
Solutions
- Re-export the Notion workspace ensuring all teamspace root folders are included so spaceIdMap covers every notionSubRootId
- Verify each entry in the export has a resolvable parent teamspace directory and no orphan pages at the zip root
- Check that docMeta.notionSubRootId is set during metadata collection; debug documentMetaMap before calling importFiles
- Pre-filter the entry list to skip documents whose sub-root is absent instead of failing the whole import
Example fix
// before
const spaceId = docMeta.notionSubRootId !== undefined && spaceIdMap.get(docMeta.notionSubRootId)
if (spaceId === undefined || spaceId === false) {
throw new Error('Teamspace not found for document: ' + docMeta.name)
}
// after
const spaceId = docMeta.notionSubRootId !== undefined ? spaceIdMap.get(docMeta.notionSubRootId) : undefined
if (spaceId === undefined || spaceId === false) {
console.warn('Skipping document without teamspace:', docMeta.name)
continue
} Defensive patterns
Strategy: validation
Validate before calling
function canResolveTeamspace(docMeta, spaceIdMap) {
return docMeta.notionSubRootId !== undefined && Boolean(spaceIdMap.get(docMeta.notionSubRootId))
}
// call before importFiles: entries = entries.filter(e => canResolveTeamspace(documentMetaMap.get(e.id), spaceIdMap)) Type guard
function hasSubRoot(docMeta) {
return typeof docMeta.notionSubRootId === 'string' && docMeta.notionSubRootId.length > 0
} Try / catch
try {
await importNotion(ctx, ...)
} catch (err) {
if (err.message.startsWith('Teamspace not found for document: ')) {
console.error('Skipping import: missing teamspace mapping for', err.message)
return
}
throw err
} Prevention
- Always export the complete Notion workspace including all teamspace root folders
- Never rename files or folders inside the export archive
- Log documentMetaMap and spaceIdMap sizes before importing to confirm full coverage
- Validate every entry has a resolvable notionSubRootId before starting the import
When it happens
Trigger: importNotion -> importFiles encounters a file entry whose DocumentMetadata.notionSubRootId is missing from spaceIdMap, or whose spaceId resolved to false (no sub-root id at all). Typical when the Notion export contains pages outside any recognized teamspace, or metadata collection skipped/renamed a space.
Common situations: Importing a partial Notion export where the teamspace root folder was excluded; exports containing shared/guest pages whose parent space is not in the archive; renamed or restructured Notion workspaces between export and import; malformed zip layouts that break sub-root detection.
Related errors
- Importing folder entry is not supported: ${fileMeta.fileName
- DB file not found: ${docMeta.name}
- 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/50867b7b6c521eda.
Report an issue: GitHub.