payloadcms/payload · error · Error

Error fetching data from locale "${toLocale}"

Error message

Error fetching data from locale "${toLocale}"

What it means

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.

Source

Thrown at packages/ui/src/utilities/copyDataFromLocale.ts:298

      : payload.findByID({
          id: docID,
          collection: collectionSlug,
          depth: 0,
          draft: true,
          joins: false,
          locale: toLocale,
          overrideAccess: false,
          user,
          // `select` would allow us to select only the fields we need in the future
        }),
  ])

  if (fromLocaleData.status === 'rejected') {
    throw new Error(`Error fetching data from locale "${fromLocale}"`)
  }

  if (toLocaleData.status === 'rejected') {
    throw new Error(`Error fetching data from locale "${toLocale}"`)
  }

  const fields = globalSlug
    ? globals[globalSlug].config.fields
    : collections[collectionSlug].config.fields

  const fromLocaleDataWithoutID = fromLocaleData.value
  const toLocaleDataWithoutID = toLocaleData.value

  const dataWithID = overrideData
    ? fromLocaleDataWithoutID
    : mergeData(fromLocaleDataWithoutID, toLocaleDataWithoutID, fields, req, false)

  const data = removeIdIfParentIsLocalized(dataWithID, fields)

  return globalSlug
    ? await payload.updateGlobal({
        slug: globalSlug,

View on GitHub (pinned to 00c58b35c0)

Solutions

  1. Confirm `toLocale` is listed in `payload.config.localization.locales`.
  2. Verify read access to the document in `toLocale`.
  3. Inspect server logs for `toLocaleData.reason` to find the real error.
  4. Ensure the target document/draft exists before copying.
  5. Retry after resolving any transient DB issue.
Defensive patterns

Strategy: try-catch

Validate before calling

const configuredLocales =
  (req.payload.config.localization?.locales ?? []).map((l) => l.code)
if (!configuredLocales.includes(toLocale)) {
  // abort before calling copyDataFromLocale: target locale not configured
}

Type guard

function isConfiguredLocale(
  code: string,
  config: { localization?: { locales: Array<{ code: string }> } },
): boolean {
  return (config.localization?.locales ?? []).some((l) => l.code === code)
}

Try / catch

try {
  await copyDataFromLocale(args)
} catch (err) {
  if (err instanceof Error && err.message.startsWith('Error fetching data from locale')) {
    // inspect server logs for toLocaleData.reason; show user-facing message
  } else {
    throw err
  }
}

Prevention

When it happens

Trigger: `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.

Common situations: Target locale removed from config, target draft never initialized, access policy denying the target locale, transient DB failure during copy.

Related errors


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