{"record":{"id":"78a489bec6731188","repo":"payloadcms/payload","slug":"either-collectionslug-or-globalslug-must-be-provid","errorCode":null,"errorMessage":"Either collectionSlug or globalSlug must be provided","messagePattern":"Either collectionSlug or globalSlug must be provided","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/db-mongodb/src/predefinedMigrations/migrateLocalizeStatus.ts","lineNumber":81,"sourceCode":"  }\n\n  for (const global of globals) {\n    await localizeStatus({ globalSlug: global.slug, payload, req, session })\n    await cleanupSnapshotDocuments({ connection, entitySlug: global.slug, payload, session })\n  }\n\n  payload.logger.info({ msg: 'localize-status migration completed successfully' })\n}\n\n/**\n * Converts version._status (and the main document _status) from a scalar string to a\n * per-locale object for a single collection or global.\n */\nexport async function localizeStatus(args: LocalizeStatusArgs): Promise<void> {\n  const { collectionSlug, globalSlug, payload, req, session } = args\n\n  if (!collectionSlug && !globalSlug) {\n    throw new Error('Either collectionSlug or globalSlug must be provided')\n  }\n\n  if (collectionSlug && globalSlug) {\n    throw new Error('Cannot provide both collectionSlug and globalSlug')\n  }\n\n  const entitySlug = collectionSlug || globalSlug\n  // MongoDB collection names are case-insensitive and stored as lowercase\n  const versionsCollection = `_${entitySlug}_versions`.toLowerCase()\n\n  if (!payload.config.localization) {\n    throw new Error('Localization is not enabled in payload config')\n  }\n\n  // Check if versions are enabled on this collection/global\n  let entityConfig\n  if (collectionSlug) {\n    const collection = payload.config.collections.find((c) => c.slug === collectionSlug)","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/db-mongodb/src/predefinedMigrations/migrateLocalizeStatus.ts#L63-L99","documentation":"The localizeStatus migration helper requires exactly one entity identifier. Thrown when neither collectionSlug nor globalSlug is passed in LocalizeStatusArgs. This is a programmer-argument guard, not a runtime data condition.","triggerScenarios":"Calling localizeStatus() directly (outside the orchestrator migrateLocalizeStatus) with an args object where both collectionSlug and globalSlug are undefined.","commonSituations":"A custom migration or script that invokes localizeStatus without an entity slug; refactoring that dropped the slug argument.","solutions":["Pass exactly one of collectionSlug or globalSlug when calling localizeStatus.","Prefer the higher-level migrateLocalizeStatus() orchestrator which derives slugs from config automatically.","Add a unit test asserting your caller always provides a slug.","Type the caller so omitting both is a compile error (LocalizeStatusArgs already does this weakly)."],"exampleFix":"// before\nawait localizeStatus({ payload, req })\n\n// after\nawait localizeStatus({ collectionSlug: 'posts', payload, req })","handlingStrategy":"validation","validationCode":"function assertLocalizeTarget(args: { collectionSlug?: string; globalSlug?: string }) {\n  if (!args.collectionSlug && !args.globalSlug) {\n    throw new Error('localizeStatus requires collectionSlug or globalSlug')\n  }\n}","typeGuard":"type LocalizeArgs = { collectionSlug?: string; globalSlug?: string }\nfunction hasOneEntity(a: LocalizeArgs): a is { collectionSlug: string } | { globalSlug: string } {\n  return Boolean(a.collectionSlug) !== Boolean(a.globalSlug)\n}","tryCatchPattern":null,"preventionTips":["Always pass exactly one slug to localizeStatus.","Prefer the migrateLocalizeStatus() orchestrator which derives slugs from config.","Unit-test custom migration callers to guarantee a slug is present."],"tags":["db-mongodb","migration","validation","localization"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}