{"record":{"id":"81a6645be3f6506a","repo":"payloadcms/payload","slug":"cannot-provide-both-collectionslug-and-globalslug","errorCode":null,"errorMessage":"Cannot provide both collectionSlug and globalSlug","messagePattern":"Cannot provide both collectionSlug and globalSlug","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/db-mongodb/src/predefinedMigrations/migrateLocalizeStatus.ts","lineNumber":85,"sourceCode":"    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)\n    if (collection) {\n      entityConfig = collection\n    }\n  } else if (globalSlug) {","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/db-mongodb/src/predefinedMigrations/migrateLocalizeStatus.ts#L67-L103","documentation":"localizeStatus treats collectionSlug and globalSlug as mutually exclusive because it must pick the right versions collection and config lookup. Thrown when both are supplied at once.","triggerScenarios":"Calling localizeStatus() with both collectionSlug and globalSlug set, e.g. from a custom loop that iterates both lists and accidentally merges the arguments.","commonSituations":"A custom migration script building args dynamically that ends up populating both fields; copy-paste error when adding a new entity.","solutions":["Pass exactly one identifier: collectionSlug OR globalSlug, never both.","Loop collections and globals in separate branches, each calling localizeStatus with only the relevant slug.","Add an assertion/log in your caller to confirm only one is set before invoking.","Use the migrateLocalizeStatus() orchestrator which handles the split correctly."],"exampleFix":"// before\nawait localizeStatus({\n  collectionSlug: 'posts',\n  globalSlug: 'header',\n  payload,\n  req,\n})\n\n// after — two separate calls\nawait localizeStatus({ collectionSlug: 'posts', payload, req })\nawait localizeStatus({ globalSlug: 'header', payload, req })","handlingStrategy":"validation","validationCode":"function assertMutuallyExclusive(args: { collectionSlug?: string; globalSlug?: string }) {\n  if (args.collectionSlug && args.globalSlug) {\n    throw new Error('Pass collectionSlug OR globalSlug, not both')\n  }\n}","typeGuard":"function isExactlyOneEntity(a: { collectionSlug?: string; globalSlug?: string }): boolean {\n  return Boolean(a.collectionSlug) !== Boolean(a.globalSlug)\n}","tryCatchPattern":null,"preventionTips":["Loop collections and globals in separate branches.","Never merge both slug fields into one args object.","Use the orchestrator to avoid manual arg construction."],"tags":["db-mongodb","migration","validation","localization"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}