{"record":{"id":"6b30b8f9be494a64","repo":"payloadcms/payload","slug":"error-fetching-data-from-locale-tolocale","errorCode":null,"errorMessage":"Error fetching data from locale \"${toLocale}\"","messagePattern":"Error fetching data from locale \"(.+?)\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ui/src/utilities/copyDataFromLocale.ts","lineNumber":298,"sourceCode":"      : 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)\n\n  return globalSlug\n    ? await payload.updateGlobal({\n        slug: globalSlug,","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/ui/src/utilities/copyDataFromLocale.ts#L280-L316","documentation":"Thrown after copyDataFromLocale's Promise.allSettled when the TARGET-locale fetch (findByID or findGlobal) was rejected. Symmetric to the source-locale error: the underlying rejection reason is in `toLocaleData.reason` and is logged server-side, not in this message. The target read is needed so the source values can be merged into (rather than overwrite) the target's existing localized data.","triggerScenarios":"`toLocale` is not in config.localization.locales; the document has no draft in the target locale; the user lacks read access to the target locale; docID does not exist; DB error during the target read.","commonSituations":"Target locale removed from config, target draft never initialized, access policy denying the target locale, transient DB failure during copy.","solutions":["Confirm `toLocale` is listed in `payload.config.localization.locales`.","Verify read access to the document in `toLocale`.","Inspect server logs for `toLocaleData.reason` to find the real error.","Ensure the target document/draft exists before copying.","Retry after resolving any transient DB issue."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const configuredLocales =\n  (req.payload.config.localization?.locales ?? []).map((l) => l.code)\nif (!configuredLocales.includes(toLocale)) {\n  // abort before calling copyDataFromLocale: target locale not configured\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    // inspect server logs for toLocaleData.reason; show user-facing message\n  } else {\n    throw err\n  }\n}","preventionTips":["Ensure both source and target locales are present in config.localization.locales.","Verify read access on the target locale before enabling copy.","Log `toLocaleData.reason` server-side for diagnosis.","Retry transient DB failures 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"}