{"record":{"id":"3d04229f25bef62c","repo":"medusajs/medusa","slug":"locale-with-code-req-params-code-was-not-found","errorCode":null,"errorMessage":"Locale with code: ${req.params.code} was not found","messagePattern":"Locale with code: (.+?) was not found","errorType":"http","errorClass":"MedusaError","httpStatus":404,"severity":"error","filePath":"packages/medusa/src/api/admin/locales/[code]/route.ts","lineNumber":37,"sourceCode":"  const query = req.scope.resolve(ContainerRegistrationKeys.QUERY)\n\n  const {\n    data: [locale],\n  } = await query.graph(\n    {\n      entity: \"locale\",\n      filters: {\n        code: req.params.code,\n      },\n      fields: req.queryConfig.fields,\n    },\n    {\n      cache: { enable: true },\n    }\n  )\n\n  if (!locale) {\n    throw new MedusaError(\n      MedusaError.Types.NOT_FOUND,\n      `Locale with code: ${req.params.code} was not found`\n    )\n  }\n\n  res.status(200).json({ locale })\n}\n\ndefineFileConfig({\n  isDisabled: () => !FeatureFlag.isFeatureEnabled(TranslationFeatureFlag.key),\n})\n","sourceCodeStart":19,"sourceCodeEnd":49,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/medusa/src/api/admin/locales/[code]/route.ts#L19-L49","documentation":"Thrown by GET /admin/locales/:code when the locale lookup for the requested code returns nothing. The route queries available locales (with caching enabled) and matches on the code param; an unknown or unsupported code yields this NOT_FOUND error.","triggerScenarios":"Calling GET /admin/locales/en-US with an invalid, unsupported, or malformed code (e.g. 'enus', 'zz', or a code not returned by the locale service).","commonSituations":"Hardcoding a locale code that the deployment does not support, case/separator mismatches ('en_us' vs 'en-us'), or consuming a locale value from external data that was never validated.","solutions":["Call GET /admin/locales (list) and pick codes from the response","Normalize the code to the exact format the list returns (usually lowercase hyphenated, e.g. en-us)","Filter or map user-supplied locale input against the supported list before use"],"exampleFix":"// before\nconst { locale } = await sdk.client.fetch(`/admin/locales/${code}`)\n\n// after\nconst { locales } = await sdk.client.fetch(\"/admin/locales\")\nconst found = locales.find((l) => l.code === code.toLowerCase())\nif (!found) throw new Error(`Unsupported locale: ${code}`)","handlingStrategy":"validation","validationCode":"const { locales } = await sdk.client.fetch(\"/admin/locales\")\nconst codes = new Set(locales.map((l: any) => l.code))\nif (!codes.has(code)) throw new Error(`Unsupported locale: ${code}`)","typeGuard":"const isLocaleCode = (code: string, supported: string[]) =>\n  supported.includes(code.toLowerCase())","tryCatchPattern":"try {\n  return await getLocale(code)\n} catch (e: any) {\n  if (e.statusCode === 404) return fallbackLocale\n  throw e\n}","preventionTips":["Drive locale pickers from the locales list endpoint","Normalize case/separator before sending","Cache the supported set and refresh on deploy"],"tags":["admin","locales","not-found","i18n"],"backgroundTag":"resource-not-found","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}