{"record":{"id":"b666e5cb3b152fbf","repo":"payloadcms/payload","slug":"error-fetching-data-from-locale-fromlocale","errorCode":null,"errorMessage":"Error fetching data from locale \"${fromLocale}\"","messagePattern":"Error fetching data from locale \"(.+?)\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ui/src/utilities/copyDataFromLocale.ts","lineNumber":294,"sourceCode":"          overrideAccess: false,\n          user,\n          // `select` would allow us to select only the fields we need in the future\n        })\n      : payload.findByID({\n          id: docID,\n          collection: collectionSlug,\n          depth: 0,\n          draft: true,\n          joins: false,\n          locale: toLocale,\n          overrideAccess: false,\n          user,\n          // `select` would allow us to select only the fields we need in the future\n        }),\n  ])\n\n  if (fromLocaleData.status === 'rejected') {\n    throw new Error(`Error fetching data from locale \"${fromLocale}\"`)\n  }\n\n  if (toLocaleData.status === 'rejected') {\n    throw new Error(`Error fetching data from locale \"${toLocale}\"`)\n  }\n\n  const fields = globalSlug\n    ? globals[globalSlug].config.fields\n    : collections[collectionSlug].config.fields\n\n  const fromLocaleDataWithoutID = fromLocaleData.value\n  const toLocaleDataWithoutID = toLocaleData.value\n\n  const dataWithID = overrideData\n    ? fromLocaleDataWithoutID\n    : mergeData(fromLocaleDataWithoutID, toLocaleDataWithoutID, fields, req, false)\n\n  const data = removeIdIfParentIsLocalized(dataWithID, fields)","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/ui/src/utilities/copyDataFromLocale.ts#L276-L312","documentation":"Thrown after copyDataFromLocale runs its two locale reads through Promise.allSettled; the SOURCE-locale fetch (findByID for a collection, or findGlobal) was rejected. This message is a wrapper - the real underlying error lives in `fromLocaleData.reason` (DB error, access denial, not-found, bad locale code) and is logged server-side but not surfaced in the message.","triggerScenarios":"`fromLocale` is not in config.localization.locales; the collection/global is not localized; the document has no draft in that locale; the user lacks read access; the docID does not exist; a transient DB error during the admin copy action.","commonSituations":"Requesting a locale that was removed from config, copying from a locale whose draft was never created, restricted access policies on the source locale, transient DB/connectivity outage during the copy-locale admin action.","solutions":["Confirm `fromLocale` is listed in `payload.config.localization.locales` and the collection/global is localized.","Verify the user has read access to the document in `fromLocale`.","Inspect the server logs for `fromLocaleData.reason` to find the true underlying error (DB, access, not-found).","Ensure the document exists and has a draft in the source locale before invoking copy.","Retry the copy action after resolving transient DB issues."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const configuredLocales =\n  (req.payload.config.localization?.locales ?? []).map((l) => l.code)\nif (!configuredLocales.includes(fromLocale)) {\n  // abort before calling copyDataFromLocale: source locale not configured\n}\n// optional: confirm the doc has a draft in fromLocale\nconst exists = await payload.findByID({\n  id: docID,\n  collection: collectionSlug,\n  depth: 0,\n  draft: true,\n  locale: fromLocale,\n  overrideAccess: false,\n  user,\n}).catch(() => null)\nif (!exists) {\n  // abort: nothing to copy from this locale\n}","typeGuard":"function isConfiguredLocale(\n  code: string,\n  config: { localization?: { locales: Array<{ code: string }> } },\n): boolean {\n  return (config.localization?.locales ?? []).some((l) => l.code === code)\n}","tryCatchPattern":"try {\n  await copyDataFromLocale(args)\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith('Error fetching data from locale')) {\n    // surface a user-facing message; the real reason is in the server logs\n  } else {\n    throw err\n  }\n}","preventionTips":["Gate the copy-locale UI by the configured locale list.","Log `fromLocaleData.reason` server-side so the root cause (access/DB/not-found) is diagnosable.","Confirm the source document has a draft in `fromLocale` before enabling the action.","Retry transient DB failures via the admin action after resolving the underlying issue."],"tags":["localization","i18n","copy-locale","data-fetch"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}