medusajs/medusa · error · MedusaError
Region with id ${req.filterableFields.region_id} not found w
Error message
Region with id ${req.filterableFields.region_id} not found when populating the tax context What it means
Thrown by getTaxInclusivityInfo in set-tax-context when req.filterableFields.region_id references a region that does not exist. The middleware needs the region's automatic_taxes setting to decide tax-inclusive pricing behavior, so an unknown region aborts the request.
Source
Thrown at packages/medusa/src/api/utils/middlewares/products/set-tax-context.ts:58
taxInclusivityContext: inclusivity,
}
return next()
} catch (e) {
next(e)
}
}
}
const getTaxInclusivityInfo = async (req: MedusaRequest) => {
const region = await refetchEntity({
entity: "region",
idOrFilter: req.filterableFields.region_id as string,
scope: req.scope,
fields: ["automatic_taxes"],
})
if (!region) {
throw new MedusaError(
MedusaError.Types.INVALID_DATA,
`Region with id ${req.filterableFields.region_id} not found when populating the tax context`
)
}
return {
automaticTaxes: region.automatic_taxes,
}
}
const getTaxLinesContext = async (req: MedusaRequest) => {
if (!req.filterableFields.country_code) {
return
}
const taxContext = {
address: {
country_code: req.filterableFields.country_code as string,View on GitHub (pinned to 5e06e544a2)
Solutions
- Fetch current regions with GET /store/regions and use one of those ids
- Invalidate cached region ids in the client whenever regions change
- Omit region_id and let the store default region apply
Example fix
// before GET /store/products?region_id=reg_deleted // after GET /store/products?region_id=reg_valid
Defensive patterns
Strategy: validation
Validate before calling
// validate region before any request that builds tax context
const { regions } = await sdk.store.region.list()
const valid = regions.some((r) => r.id === requestedRegionId)
if (!valid) requestedRegionId = regions[0]?.id Type guard
const isKnownRegion = (id: string | undefined, known: string[]): id is string => !!id && known.includes(id)
Try / catch
try {
await sdk.store.product.list({ region_id: id })
} catch (e) {
if (e.type === 'invalid_data' && /tax context/.test(e.message)) {
// drop the stale region and refetch with a valid/default one
}
throw e
} Prevention
- Treat region ids as volatile; resolve them from /store/regions at runtime
- Add monitoring for 400s containing 'region' to catch stale-id drift early
When it happens
Trigger: GET /store/products?region_id=<nonexistent-or-deleted id> on an endpoint that runs setTaxContext (store product routes). Same stale/typo'd region ids as the pricing variant of this error.
Common situations: Region deleted and recreated with a new id while clients still send the old one; multi-environment id mixing; typo in a manually constructed URL.
Related errors
- Region with id: ${req.params.id} was not found
- Region with id ${req.filterableFields.region_id} not found w
- invalid_data
- NOT_FOUND
- NOT_ALLOWED
AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27).
Data as JSON: /api/errors/d8343a9b9bea6eef.
Report an issue: GitHub.