{"record":{"id":"0d336deb397cca98","repo":"payloadcms/payload","slug":"the-collection-with-slug-string-collectionslug-0d336d","errorCode":null,"errorMessage":"The collection with slug ${String(collectionSlug)} cannot be duplicated.","messagePattern":"The collection with slug (.+?) cannot be duplicated\\.","errorType":"http","errorClass":"APIError","httpStatus":400,"severity":"error","filePath":"packages/payload/src/collections/operations/local/duplicate.ts","lineNumber":121,"sourceCode":"    disableTransaction,\n    draft,\n    overrideAccess = true,\n    populate,\n    select,\n    selectedLocales,\n    showHiddenFields,\n  } = options\n\n  const collection = payload.collections[collectionSlug]\n\n  if (!collection) {\n    throw new APIError(\n      `The collection with slug ${String(collectionSlug)} can't be found. Duplicate Operation.`,\n    )\n  }\n\n  if (collection.config.disableDuplicate === true) {\n    throw new APIError(\n      `The collection with slug ${String(collectionSlug)} cannot be duplicated.`,\n      400,\n    )\n  }\n\n  const req = await createLocalReq(options as CreateLocalReqOptions, payload)\n\n  return duplicateOperation<TSlug, TSelect>({\n    id,\n    collection,\n    data,\n    depth,\n    disableTransaction,\n    draft,\n    overrideAccess,\n    populate,\n    req,\n    select,","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/payload/src/collections/operations/local/duplicate.ts#L103-L139","documentation":"Thrown by duplicateLocal at packages/payload/src/collections/operations/local/duplicate.ts:121 with HTTP 400 when the resolved collection has `disableDuplicate: true` in its config. Unlike the 'can't be found' guard (error 144), this means the collection exists but the operator has explicitly turned off duplication. It fires after the collection lookup but before `createLocalReq`.","triggerScenarios":"Calling `payload.duplicate({ collection: 'orders', id })` on a collection whose config sets `disableDuplicate: true`; a user clicking the 'Duplicate' action in the admin UI on a collection where duplication is disabled; an automated copy routine that does not check the config.","commonSituations":"Enabling `disableDuplicate` on sensitive collections (payments, audit logs) and then forgetting downstream code/UI still attempts duplication; a plugin or team member setting `disableDuplicate: true` during a refactor.","solutions":["Check the collection config: if `disableDuplicate: true`, duplication is intentionally blocked — pick a different approach (e.g., explicit create with copied fields).","If duplication should be allowed, remove or set `disableDuplicate: false` on the collection config.","Guard UI/admin surfaces so the 'Duplicate' button is hidden for collections with `disableDuplicate`."],"exampleFix":"// before\nawait payload.duplicate({ collection: 'orders', id }) // config: { slug: 'orders', disableDuplicate: true }\n\n// after — either allow it in config:\n// collections/[Orders].ts -> disableDuplicate: false\n// or copy manually:\nconst orig = await payload.findByID({ collection: 'orders', id, overrideAccess: true })\nawait payload.create({ collection: 'orders', data: { ...orig, _id: undefined, id: undefined } })","handlingStrategy":"validation","validationCode":"function canDuplicate(payload: Payload, slug: CollectionSlug): boolean {\n  const collection = payload.collections[slug]\n  return Boolean(collection) && collection.config.disableDuplicate !== true\n}\n\nif (canDuplicate(payload, 'orders')) {\n  await payload.duplicate({ collection: 'orders', id })\n} else {\n  // duplication intentionally disabled — fall back to explicit create\n}","typeGuard":"const isDuplicable = (payload: Payload, slug: CollectionSlug): boolean => {\n  const c = payload.collections[slug]\n  return Boolean(c) && c.config.disableDuplicate !== true\n}","tryCatchPattern":"try {\n  await payload.duplicate({ collection: slug, id })\n} catch (err) {\n  if (err instanceof APIError && err.status === 400 && /cannot be duplicated/.test(err.message)) {\n    // disabled by config — use a manual create fallback or surface a user message\n  } else throw err\n}","preventionTips":["Hide the Duplicate UI action for collections with disableDuplicate: true.","Document which collections disable duplication so downstream code knows.","If you must copy, use create() with an explicitly sanitized copy of the doc."],"tags":["local-api","duplicate","configuration","collection-config"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}