payloadcms/payload · error · Error

Import document not found: ${importId}

Error message

Import document not found: ${importId}

What it means

The createCollectionImport background task fetches the import tracking document via req.payload.findByID({ id: importId, collection: importCollection }). If it returns null the task throws a plain Error. This usually means the import record was deleted, the ID is wrong, or the wrong collection slug was supplied.

Source

Thrown at packages/plugin-import-export/src/import/getCreateImportCollectionTask.ts:46

      const {
        batchSize,
        debug,
        defaultVersionStatus,
        importCollection,
        importId,
        maxLimit,
        userCollection,
        userID,
      } = input

      // Fetch the import document to get all necessary data
      const importDoc = await req.payload.findByID({
        id: importId,
        collection: importCollection,
      })

      if (!importDoc) {
        throw new Error(`Import document not found: ${importId}`)
      }

      // Get the collection config for the imports collection
      const collectionConfig = req.payload.config.collections.find(
        (c) => c.slug === importCollection,
      )

      if (!collectionConfig) {
        throw new Error(`Collection config not found for: ${importCollection}`)
      }

      // Retrieve the file using getFileFromDoc (handles both local and cloud storage)
      const file = await getFileFromDoc({
        collectionConfig,
        doc: {
          filename: importDoc.filename as string,
          mimeType: importDoc.mimeType as string | undefined,
          url: importDoc.url as string | undefined,

View on GitHub (pinned to 00c58b35c0)

Solutions

  1. Confirm the import document still exists: findByID({ id: importId, collection: importCollection }).
  2. Verify importCollection is the correct imports-collection slug.
  3. If the record is gone, discard the stale job rather than retrying it unchanged.
Defensive patterns

Strategy: validation

Validate before calling

const importDoc = await req.payload.findByID({
  id: importId,
  collection: importCollection,
})
if (!importDoc) {
  // do not enqueue/continue the job; surface a clear error
  throw new Error(`No import record ${importId} in ${importCollection}`)
}

Try / catch

try {
  // task body
} catch (err) {
  if (err instanceof Error && /Import document not found/.test(err.message)) {
    // mark job as permanently failed, do not retry unchanged
  } else throw err
}

Prevention

When it happens

Trigger: importId is stale/typoed; the import document was deleted between enqueue and execution; importCollection slug points to the wrong collection so nothing matches the ID.

Common situations: Job retries run after a DB reset or after the user cancelled/deleted the import; queue replayed a stale job ID; misconfigured importCollection slug.

Related errors


AI-assisted analysis of payloadcms/payload@00c58b35c0 (2026-08-12). Data as JSON: /api/errors/a857af86232a29b7. Report an issue: GitHub.