payloadcms/payload · error · APIError
The collection with slug ${String(collectionSlug)} can't be
Error message
The collection with slug ${String(collectionSlug)} can't be found. Find Versions Operation. What it means
Thrown by the Local API `findVersions` wrapper in packages/payload/src/collections/operations/local/findVersions.ts:129 when `payload.findVersions({ collection })` references a slug absent from `payload.collections`. Defaults to HTTP 500. Applies only to versioned collections.
Source
Thrown at packages/payload/src/collections/operations/local/findVersions.ts:129
const {
collection: collectionSlug,
depth,
limit,
overrideAccess = true,
page,
pagination = true,
populate,
select,
showHiddenFields,
sort,
trash = false,
where,
} = options
const collection = payload.collections[collectionSlug]
if (!collection) {
throw new APIError(
`The collection with slug ${String(collectionSlug)} can't be found. Find Versions Operation.`,
)
}
return findVersionsOperation({
collection,
depth,
limit,
overrideAccess,
page,
pagination,
populate,
req: await createLocalReq(options as CreateLocalReqOptions, payload),
select,
showHiddenFields,
sort,
trash,
where,View on GitHub (pinned to 00c58b35c0)
Solutions
- Match the slug to the collection config's `slug` value.
- Confirm versions are still enabled on the collection.
- Log `Object.keys(payload.collections)` to verify registration.
- Avoid `as CollectionSlug` casts on runtime strings.
Example fix
// before
await payload.findVersions({ collection: 'page' }) // slug is 'pages'
// after
await payload.findVersions({ collection: 'pages' }) Defensive patterns
Strategy: validation
Validate before calling
function assertCollectionSlug(payload: Payload, slug: string): void {
if (!(slug in payload.collections)) {
throw new Error(`Unknown collection slug '${slug}'`)
}
}
assertCollectionSlug(payload, 'pages')
await payload.findVersions({ collection: 'pages' }) Type guard
const slugIsRegistered = (payload: Payload, slug: string): slug is CollectionSlug =>
slug in (payload.collections as Record<string, unknown>)
if (slugIsRegistered(payload, slug)) {
await payload.findVersions({ collection: slug })
} Try / catch
try {
await payload.findVersions({ collection: slug })
} catch (err) {
if (err instanceof APIError && /Find Versions Operation/.test(err.message)) {
// unknown slug — correct it
} else throw err
} Prevention
- Confirm versions are still enabled on the collection.
- Keep slug constants in sync with config.
- Avoid `as CollectionSlug` casts on dynamic input.
When it happens
Trigger: Calling `payload.findVersions({ collection: 'page' })` with a misspelled slug; listing versions for a collection that no longer has versions enabled; calling before collections are registered.
Common situations: Slug typo or stale constant; collection renamed/removed; versions config removed; `as CollectionSlug` cast on dynamic input.
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/de55663b713367f7.
Report an issue: GitHub.