payloadcms/payload · error · Error

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

Error message

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

What it means

Thrown by migrateSqliteLocalizeStatus when the supplied collectionSlug is not found in payload.config.collections, or the supplied globalSlug is not found in payload.config.globals. The migration looks up the entity config to read its versions settings; a missing slug means there is nothing to migrate.

Source

Thrown at packages/drizzle/src/sqlite/predefinedMigrations/localize-status/index.ts:48

  const versionsTable = collectionSlug
    ? `_${toSnakeCase(collectionSlug)}_v`
    : `_${toSnakeCase(globalSlug)}_v`
  const localesTable = `${versionsTable}_locales`

  if (!payload.config.localization) {
    throw new Error('Localization is not enabled in payload config')
  }

  // Check if versions are enabled on this collection/global
  let entityConfig
  if (collectionSlug) {
    entityConfig = payload.config.collections.find((c) => c.slug === collectionSlug)
  } else if (globalSlug) {
    entityConfig = payload.config.globals.find((g) => g.slug === globalSlug)
  }

  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) =>
      typeof locale === 'string' ? locale : locale.code,
    )

View on GitHub (pinned to 00c58b35c0)

Solutions

  1. Confirm the slug matches the `slug` field of a collection or global in the payload config you passed.
  2. If the entity was renamed, update the migration call to the new slug.
  3. Run the migration against the payload instance whose config actually defines that entity.

Example fix

// before
await migrateSqliteLocalizeStatus({ db, payload, collectionSlug: 'post' }) // slug is 'posts'
// after
await migrateSqliteLocalizeStatus({ db, payload, collectionSlug: 'posts' })
Defensive patterns

Strategy: validation

Validate before calling

function assertEntityExists(payload, args) {
  const exists = args.collectionSlug
    ? payload.config.collections.some(c => c.slug === args.collectionSlug)
    : payload.config.globals.some(g => g.slug === args.globalSlug)
  if (!exists) throw new Error(`Unknown slug: ${args.collectionSlug || args.globalSlug}`)
}

Prevention

When it happens

Trigger: Passing a collectionSlug or globalSlug that is misspelled, has been renamed, or belongs to a different payload instance/config than the one passed in `payload`.

Common situations: Slug renamed in config but the migration script still uses the old slug; pointing the migration at a payload object whose config does not include the target collection/global.

Related errors


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