medusajs/medusa · error · MedusaError
Locale with code: ${req.params.code} was not found
Error message
Locale with code: ${req.params.code} was not found What it means
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.
Source
Thrown at packages/medusa/src/api/admin/locales/[code]/route.ts:37
const query = req.scope.resolve(ContainerRegistrationKeys.QUERY)
const {
data: [locale],
} = await query.graph(
{
entity: "locale",
filters: {
code: req.params.code,
},
fields: req.queryConfig.fields,
},
{
cache: { enable: true },
}
)
if (!locale) {
throw new MedusaError(
MedusaError.Types.NOT_FOUND,
`Locale with code: ${req.params.code} was not found`
)
}
res.status(200).json({ locale })
}
defineFileConfig({
isDisabled: () => !FeatureFlag.isFeatureEnabled(TranslationFeatureFlag.key),
})
View on GitHub (pinned to 5e06e544a2)
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
Example fix
// before
const { locale } = await sdk.client.fetch(`/admin/locales/${code}`)
// after
const { locales } = await sdk.client.fetch("/admin/locales")
const found = locales.find((l) => l.code === code.toLowerCase())
if (!found) throw new Error(`Unsupported locale: ${code}`) Defensive patterns
Strategy: validation
Validate before calling
const { locales } = await sdk.client.fetch("/admin/locales")
const codes = new Set(locales.map((l: any) => l.code))
if (!codes.has(code)) throw new Error(`Unsupported locale: ${code}`) Type guard
const isLocaleCode = (code: string, supported: string[]) => supported.includes(code.toLowerCase())
Try / catch
try {
return await getLocale(code)
} catch (e: any) {
if (e.statusCode === 404) return fallbackLocale
throw e
} Prevention
- Drive locale pickers from the locales list endpoint
- Normalize case/separator before sending
- Cache the supported set and refresh on deploy
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Invite with id: ${id} was not found
- Price list with id: ${id} was not found
- Price list with id: ${id} was not found
- Product category with id: ${req.params.id} was not found
- Product option value with id "${valueId}" was not found for
AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27).
Data as JSON: /api/errors/3d04229f25bef62c.
Report an issue: GitHub.