payloadcms/payload · error · Error
${collectionSlug ? 'Collection' : 'Global'} not found: ${col
Error message
${collectionSlug ? 'Collection' : 'Global'} not found: ${collectionSlug || globalSlug} What it means
localizeStatus looks up the provided slug in payload.config.collections (for collectionSlug) or payload.config.globals (for globalSlug). If neither list contains a matching slug, it throws with the entity type and slug inlined.
Source
Thrown at packages/db-mongodb/src/predefinedMigrations/migrateLocalizeStatus.ts:111
throw new Error('Localization is not enabled in payload config')
}
// Check if versions are enabled on this collection/global
let entityConfig
if (collectionSlug) {
const collection = payload.config.collections.find((c) => c.slug === collectionSlug)
if (collection) {
entityConfig = collection
}
} else if (globalSlug) {
const global = payload.config.globals.find((g) => g.slug === globalSlug)
if (global) {
entityConfig = global
}
}
if (!entityConfig) {
throw new Error(
`${collectionSlug ? 'Collection' : 'Global'} not found: ${collectionSlug || globalSlug}`,
)
}
payload.logger.info({
msg: `Starting _status localization migration for ${collectionSlug ? 'collection' : 'global'}: ${entitySlug}`,
})
// Check if versions are enabled in config (skip if not)
if (!entityConfig.versions) {
payload.logger.info({
msg: `Skipping migration for ${collectionSlug ? 'collection' : 'global'}: ${entitySlug} - versions not enabled`,
})
return
}
// Get MongoDB connection
const connection = (payload.db as any).connectionView on GitHub (pinned to 00c58b35c0)
Solutions
- Confirm the slug exists in payload.config.collections (or globals) and matches exactly (case-sensitive).
- Update your migration caller to use the current slug after a rename.
- Use the migrateLocalizeStatus() orchestrator which derives slugs from config and never passes a missing one.
- Log payload.config.collections.map(c => c.slug) before calling to verify.
Example fix
// before — slug renamed from 'posts' to 'articles'
await localizeStatus({ collectionSlug: 'posts', payload, req })
// after
await localizeStatus({ collectionSlug: 'articles', payload, req }) Defensive patterns
Strategy: validation
Validate before calling
function assertEntityExists(args: { collectionSlug?: string; globalSlug?: string; payload: { config: { collections: { slug: string }[]; globals: { slug: string }[] } } }) {
const { collectionSlug, globalSlug, payload } = args
const exists = collectionSlug
? payload.config.collections.some((c) => c.slug === collectionSlug)
: payload.config.globals.some((g) => g.slug === globalSlug)
if (!exists) throw new Error(`Entity not found: ${collectionSlug ?? globalSlug}`)
} Type guard
function entityExists(slug: string, payload: { config: { collections: { slug: string }[]; globals: { slug: string }[] } }, kind: 'collection' | 'global'): boolean {
return kind === 'collection'
? payload.config.collections.some((c) => c.slug === slug)
: payload.config.globals.some((g) => g.slug === slug)
} Prevention
- Use the migrateLocalizeStatus() orchestrator which only iterates existing entities.
- Update migration callers after renaming a slug.
- Verify slug spelling against config before invoking.
When it happens
Trigger: Calling localizeStatus({ collectionSlug: 'x' }) when no collection with slug 'x' exists in config (renamed/removed slug, typo), or { globalSlug: 'y' } when no such global is configured.
Common situations: Slug was renamed and the migration caller still uses the old slug; typo in the slug; calling localizeStatus for an entity not present in the current config; running the migration in an environment with a trimmed config.
Related errors
- Either collectionSlug or globalSlug must be provided
- Cannot provide both collectionSlug and globalSlug
- Localization is not enabled in payload config
- Migration aborted: version._status field not found or has un
- Invalid template given
AI-assisted analysis of payloadcms/payload@00c58b35c0 (2026-08-12).
Data as JSON: /api/errors/ab56a7728a4ac4ca.
Report an issue: GitHub.