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 pricing context What it means
Thrown by setPricingContext when the region_id supplied on the request (req.filterableFields.region_id) does not correspond to an existing region. The middleware fetches the region to build pricing context (currency, tax rates) and refuses to continue with an unknown region.
Source
Thrown at packages/medusa/src/api/utils/middlewares/products/set-pricing-context.ts:43
return next()
}
// We validate the region ID in the previous middleware
const region = await refetchEntity({
entity: "region",
idOrFilter: req.filterableFields.region_id!,
scope: req.scope,
fields: ["id", "currency_code"],
options: {
cache: {
enable: true,
},
},
})
if (!region) {
try {
throw new MedusaError(
MedusaError.Types.INVALID_DATA,
`Region with id ${req.filterableFields.region_id} not found when populating the pricing context`
)
} catch (e) {
return next(e)
}
}
const pricingContext: MedusaPricingContext = {
region_id: region.id,
currency_code: region.currency_code,
}
// Find all the customer groups the customer is a part of and set
if (req.auth_context?.actor_id) {
const { data: customerGroups } = await refetchEntities({
entity: "customer_group",
idOrFilter: { customers: { id: req.auth_context.actor_id } },View on GitHub (pinned to 5e06e544a2)
Solutions
- List valid regions via GET /store/regions and use a current id
- If regions were re-seeded, clear cached region ids in the storefront (localStorage/cookies)
- Pass no region_id and rely on the store's default region instead
Example fix
// before GET /store/products?region_id=reg_stale // after GET /store/products?region_id=reg_current
Defensive patterns
Strategy: validation
Validate before calling
const { regions } = await sdk.store.region.list()
const regionId = regions.find(r => r.id === requestedId)?.id
if (!regionId) {
requestedId = regions[0]?.id // or re-prompt
}
const products = await sdk.store.product.list({ region_id: regionId }) Type guard
const isExistingRegionId = (id: string, regions: {id: string}[]): boolean =>
regions.some(r => r.id === id) Try / catch
try {
await sdk.store.product.list({ region_id: id })
} catch (e) {
if (e.type === 'invalid_data' && /not found when populating the pricing context/.test(e.message)) {
// refresh cached regions and retry
}
throw e
} Prevention
- Refresh cached region ids on app start instead of persisting them indefinitely
- When deleting/recreating regions, version-bump the client's region cache
When it happens
Trigger: GET /store/products?region_id=reg_does_not_exist (deleted region, id from another environment, or a typo). Any store request that populates filterableFields.region_id with a stale value.
Common situations: Frontend caching an old region id after regions were re-created; copying ids across environments; region soft-deleted while the storefront still references it.
Related errors
- Region with id: ${req.params.id} was not found
- Missing required pricing context to calculate prices - regio
- Region with id ${req.filterableFields.region_id} not found w
- invalid_data
- invalid_data
AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27).
Data as JSON: /api/errors/a58f5d03439022e2.
Report an issue: GitHub.