{"record":{"id":"a3458198eb7fdd75","repo":"payloadcms/payload","slug":"collection-with-slug-collectionslug-not-found-a34581","errorCode":null,"errorMessage":"Collection with slug ${collectionSlug} not found","messagePattern":"Collection with slug (.+?) not found","errorType":"http","errorClass":"APIError","httpStatus":400,"severity":"error","filePath":"packages/plugin-import-export/src/import/createImport.ts","lineNumber":119,"sourceCode":"\n  if (debug) {\n    req.payload.logger.debug({\n      fileName: file.name,\n      fileSize: file.data.length,\n      mimeType: file.mimetype,\n      msg: 'File info',\n    })\n  }\n\n  const collectionConfig = req.payload.config.collections.find(\n    ({ slug }) => slug === collectionSlug,\n  )\n\n  if (!collectionConfig) {\n    if (!collectionSlug) {\n      throw new APIError('Collection slug is required', 400, null, true)\n    }\n    throw new APIError(`Collection with slug ${collectionSlug} not found`, 400, null, true)\n  }\n\n  // Get disabled fields configuration\n  const disabledFields =\n    collectionConfig.admin?.custom?.['plugin-import-export']?.disabledFields ?? []\n\n  const importHooks = collectionConfig.custom?.['plugin-import-export']?.importHooks\n\n  // Get beforeImport functions for field transformations\n  const importFieldHooks = getImportFieldFunctions({\n    fields: collectionConfig.flattenedFields || [],\n  })\n\n  // Parse the file data\n  let originalDocs: Record<string, unknown>[] | undefined\n  let documents: Record<string, unknown>[]\n  if (format === 'csv') {\n    const rawData = await parseCSV({","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/plugin-import-export/src/import/createImport.ts#L101-L137","documentation":"createImport resolves the target collection from req.payload.config.collections by slug. If no registered collection matches collectionSlug, it throws a 400. (Note: the inner `if (!collectionSlug)` is dead code since line 94 already guards the empty-slug case.)","triggerScenarios":"collectionSlug is misspelled, refers to a collection not added to the Payload config, or belongs to a different Payload instance. Also when a collection was renamed but the import caller still uses the old slug.","commonSituations":"Renaming a collection without updating import config; importing into a collection declared by a plugin that was never installed; copy-paste of a slug from another project.","solutions":["Verify collectionSlug exactly matches a slug in payload.config.collections.","Log req.payload.config.collections.map(c => c.slug) at the call site to confirm membership.","If the collection lives in a plugin, ensure the plugin is added to the config before this runs."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const slugs = new Set(req.payload.config.collections.map((c) => c.slug))\nif (!slugs.has(collectionSlug)) {\n  throw new Error(`Unknown collection slug: ${collectionSlug}`)\n}\nawait createImport({ collectionSlug, ... })","typeGuard":"const isRegisteredSlug = (slug: string, req: PayloadRequest): boolean =>\n  req.payload.config.collections.some((c) => c.slug === slug)","tryCatchPattern":null,"preventionTips":["Centralize slug references as named constants instead of string literals.","Add a startup self-check that all import target slugs exist in config.","After renaming a collection, grep for the old slug across import callers."],"tags":["config","import","plugin-import-export"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}