payloadcms/payload · error · Error

${collectionSlug ? 'Collection' : 'Global'} not found: ${col

Error message

${collectionSlug ? 'Collection' : 'Global'} not found: ${collectionSlug || globalSlug}

What it means

Lookup error from `migratePostgresLocalizeStatus`: the supplied `collectionSlug`/`globalSlug` does not match any collection or global in `payload.config`. The migration derives the versions/locales table name from the slug, so an unknown slug has no schema to operate on.

Source

Thrown at packages/drizzle/src/postgres/predefinedMigrations/localize-status/index.ts:56

    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}`,
  })

  // Get filtered locales if filterAvailableLocales is defined
  let locales = payload.config.localization.localeCodes
  if (typeof payload.config.localization.filterAvailableLocales === 'function') {
    const filteredLocaleObjects = await payload.config.localization.filterAvailableLocales({
      locales: payload.config.localization.locales,
      req,
    })
    locales = filteredLocaleObjects.map((locale) => locale.code)
  }
  payload.logger.info({ msg: `Locales: ${locales.join(', ')}` })

View on GitHub (pinned to 00c58b35c0)

Solutions

  1. Verify the exact slug in `payload.config` and pass that string (collection/global slugs are case-sensitive).
  2. Ensure any plugin that registers the target collection/global is loaded in the config used by the migration.
  3. If the entity was renamed, run the migration against its new slug.

Example fix

// before
await migratePostgresLocalizeStatus({ collectionSlug: 'Post', ... }) // wrong case
// after
await migratePostgresLocalizeStatus({ collectionSlug: 'posts', ... }) // matches config slug
Defensive patterns

Strategy: validation

Validate before calling

const knownSlugs = new Set([
  ...payload.config.collections.map(c => c.slug),
  ...payload.config.globals.map(g => g.slug),
])
const slug = collectionSlug ?? globalSlug
if (!knownSlugs.has(slug)) {
  throw new Error(`Unknown entity slug: ${slug}`)
}
await migratePostgresLocalizeStatus(args)

Type guard

const isKnownSlug = (slug, payload) =>
  payload.config.collections.some(c => c.slug === slug) ||
  payload.config.globals.some(g => g.slug === slug)

Try / catch

null

Prevention

When it happens

Trigger: Passing a slug that is misspelled, has wrong casing, or refers to a collection/global not registered in the current config (e.g. from a plugin not loaded, or a renamed entity).

Common situations: Renaming a collection without updating the migration script argument; slug copied from an old config; plugin-provided collection whose plugin isn't loaded in the environment running the migration; camelCase vs kebab-case mismatch.

Related errors


AI-assisted analysis of payloadcms/payload@00c58b35c0 (2026-08-12). Data as JSON: /api/errors/93c44c862f6999c9. Report an issue: GitHub.