payloadcms/payload · error · APIError
The collection with slug ${String(collectionSlug)} cannot be
Error message
The collection with slug ${String(collectionSlug)} cannot be duplicated. What it means
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`.
Source
Thrown at packages/payload/src/collections/operations/local/duplicate.ts:121
disableTransaction,
draft,
overrideAccess = true,
populate,
select,
selectedLocales,
showHiddenFields,
} = options
const collection = payload.collections[collectionSlug]
if (!collection) {
throw new APIError(
`The collection with slug ${String(collectionSlug)} can't be found. Duplicate Operation.`,
)
}
if (collection.config.disableDuplicate === true) {
throw new APIError(
`The collection with slug ${String(collectionSlug)} cannot be duplicated.`,
400,
)
}
const req = await createLocalReq(options as CreateLocalReqOptions, payload)
return duplicateOperation<TSlug, TSelect>({
id,
collection,
data,
depth,
disableTransaction,
draft,
overrideAccess,
populate,
req,
select,View on GitHub (pinned to 00c58b35c0)
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`.
Example fix
// before
await payload.duplicate({ collection: 'orders', id }) // config: { slug: 'orders', disableDuplicate: true }
// after — either allow it in config:
// collections/[Orders].ts -> disableDuplicate: false
// or copy manually:
const orig = await payload.findByID({ collection: 'orders', id, overrideAccess: true })
await payload.create({ collection: 'orders', data: { ...orig, _id: undefined, id: undefined } }) Defensive patterns
Strategy: validation
Validate before calling
function canDuplicate(payload: Payload, slug: CollectionSlug): boolean {
const collection = payload.collections[slug]
return Boolean(collection) && collection.config.disableDuplicate !== true
}
if (canDuplicate(payload, 'orders')) {
await payload.duplicate({ collection: 'orders', id })
} else {
// duplication intentionally disabled — fall back to explicit create
} Type guard
const isDuplicable = (payload: Payload, slug: CollectionSlug): boolean => {
const c = payload.collections[slug]
return Boolean(c) && c.config.disableDuplicate !== true
} Try / catch
try {
await payload.duplicate({ collection: slug, id })
} catch (err) {
if (err instanceof APIError && err.status === 400 && /cannot be duplicated/.test(err.message)) {
// disabled by config — use a manual create fallback or surface a user message
} else throw err
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- The collection with slug ${String(collectionSlug)} can't be
- The collection with slug ${String(collectionSlug)} can't be
- The collection with slug ${String(collectionSlug)} can't be
- The collection with slug ${String(collectionSlug)} can't be
- The collection with slug ${String(collectionSlug)} can't be
AI-assisted analysis of payloadcms/payload@00c58b35c0 (2026-08-12).
Data as JSON: /api/errors/0d336deb397cca98.
Report an issue: GitHub.