{"record":{"id":"a857af86232a29b7","repo":"payloadcms/payload","slug":"import-document-not-found-importid","errorCode":null,"errorMessage":"Import document not found: ${importId}","messagePattern":"Import document not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/plugin-import-export/src/import/getCreateImportCollectionTask.ts","lineNumber":46,"sourceCode":"      const {\n        batchSize,\n        debug,\n        defaultVersionStatus,\n        importCollection,\n        importId,\n        maxLimit,\n        userCollection,\n        userID,\n      } = input\n\n      // Fetch the import document to get all necessary data\n      const importDoc = await req.payload.findByID({\n        id: importId,\n        collection: importCollection,\n      })\n\n      if (!importDoc) {\n        throw new Error(`Import document not found: ${importId}`)\n      }\n\n      // Get the collection config for the imports collection\n      const collectionConfig = req.payload.config.collections.find(\n        (c) => c.slug === importCollection,\n      )\n\n      if (!collectionConfig) {\n        throw new Error(`Collection config not found for: ${importCollection}`)\n      }\n\n      // Retrieve the file using getFileFromDoc (handles both local and cloud storage)\n      const file = await getFileFromDoc({\n        collectionConfig,\n        doc: {\n          filename: importDoc.filename as string,\n          mimeType: importDoc.mimeType as string | undefined,\n          url: importDoc.url as string | undefined,","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/plugin-import-export/src/import/getCreateImportCollectionTask.ts#L28-L64","documentation":"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.","triggerScenarios":"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.","commonSituations":"Job retries run after a DB reset or after the user cancelled/deleted the import; queue replayed a stale job ID; misconfigured importCollection slug.","solutions":["Confirm the import document still exists: findByID({ id: importId, collection: importCollection }).","Verify importCollection is the correct imports-collection slug.","If the record is gone, discard the stale job rather than retrying it unchanged."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const importDoc = await req.payload.findByID({\n  id: importId,\n  collection: importCollection,\n})\nif (!importDoc) {\n  // do not enqueue/continue the job; surface a clear error\n  throw new Error(`No import record ${importId} in ${importCollection}`)\n}","typeGuard":null,"tryCatchPattern":"try {\n  // task body\n} catch (err) {\n  if (err instanceof Error && /Import document not found/.test(err.message)) {\n    // mark job as permanently failed, do not retry unchanged\n  } else throw err\n}","preventionTips":["Don't retry a job whose import record was deleted; discard it.","Confirm importId and importCollection before enqueueing the task.","Keep import records until all jobs finish (or use soft delete with a status check)."],"tags":["jobs","import","plugin-import-export"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}