{"record":{"id":"d5e595ab833d9c6c","repo":"cube-js/cube","slug":"failed-to-generate-d3-local-via-intl-failing-back","errorCode":null,"errorMessage":"Failed to generate d3 local via Intl, failing back to en-US","messagePattern":"Failed to generate d3 local via Intl, failing back to en-US","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/cubejs-client-core/src/format-d3-numeric-locale.ts","lineNumber":97,"sourceCode":"}\n\nconst localeCache: Record<string, FormatLocaleObject> = Object.create(null);\n\nexport function getD3NumericLocale(locale: string, currencyCode = 'USD'): FormatLocaleObject {\n  const key = `${locale}:${currencyCode}`;\n  if (localeCache[key]) {\n    return localeCache[key];\n  }\n\n  let definition: FormatLocaleDefinition;\n\n  if (formatD3NumericLocale[locale]) {\n    definition = { ...formatD3NumericLocale[locale], currency: getCurrencyOverride(locale, currencyCode) };\n  } else {\n    try {\n      definition = getD3NumericLocaleFromIntl(locale, currencyCode);\n    } catch (e: unknown) {\n      console.warn('Failed to generate d3 local via Intl, failing back to en-US', e);\n\n      definition = {\n        ...formatD3NumericLocale['en-US'],\n        currency: getCurrencyOverride(locale, currencyCode)\n      };\n    }\n  }\n\n  localeCache[key] = formatLocale(definition);\n  return localeCache[key];\n}\n","sourceCodeStart":79,"sourceCodeEnd":109,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-client-core/src/format-d3-numeric-locale.ts#L79-L109","documentation":"d3 number formatting needs a locale definition. Cube first checks a bundled map of known locales; for others it derives one from Intl. If Intl-based derivation throws, the client logs this warning and falls back to the bundled en-US definition.","triggerScenarios":"getD3NumericLocale is called with a locale not present in formatD3NumericLocale and getD3NumericLocaleFromIntl(locale, currencyCode) throws (e.g. unsupported/invalid locale tag passed to Intl.NumberFormat).","commonSituations":"Browsers/runtimes without full ICU coverage for a locale; a non-standard locale string passed in the Cube query format config; running in Node builds compiled without full-icu.","solutions":["Use a locale supported by the runtime's Intl implementation","Pass one of the bundled locales in formatD3NumericLocale (e.g. en-US, de-DE)","Ensure Node has full ICU (full-icu / recent Node build) if server-side","If intentional, ignore the warning — formatting falls back to en-US"],"exampleFix":"// before\n\"format\": { currency: ['EUR'] }, locale: 'xx-XX'\n// after\n\"format\": { currency: ['EUR'] }, locale: 'de-DE'","handlingStrategy":"fallback","validationCode":"function localeSupported(l: string): boolean {\n  try { new Intl.NumberFormat(l); return true; } catch { return false; }\n}","typeGuard":"function isValidLocale(l: string): boolean {\n  try { new Intl.NumberFormat(l).resolvedOptions(); return true; } catch { return false; }\n}","tryCatchPattern":"try {\n  new Intl.NumberFormat(locale, { style: 'currency', currency });\n} catch (e) {\n  console.warn('Locale unsupported, using en-US');\n  locale = 'en-US';\n}","preventionTips":["Stick to well-known BCP-47 locale tags","Run Node with full ICU","Prefer bundled locales listed in formatD3NumericLocale"],"tags":["i18n","intl","formatting","fallback"],"backgroundTag":"unsupported-locale-fallback","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}