medusajs/medusa · error · MedusaError
Missing required pricing context to calculate prices - regio
Error message
Missing required pricing context to calculate prices - region_id
What it means
Thrown by normalizeDataForContext when building the pricing context for a store product request: no region_id was provided and the region could not be derived (no cart region, and the store tied to the publishable key has no default_region_id). Price calculation in Medusa requires a region (for currency/tax), so the middleware aborts.
Source
Thrown at packages/medusa/src/api/utils/middlewares/products/normalize-data-for-context.ts:95
// Finally, try to get it from the store defaults if not available
if (!regionId) {
const { data: stores } = await refetchEntities({
entity: "store",
scope: req.scope,
fields: ["id", "default_region_id"],
options: {
cache: {
enable: true,
},
},
})
regionId = stores[0]?.default_region_id
}
if (!regionId) {
try {
throw new MedusaError(
MedusaError.Types.INVALID_DATA,
`Missing required pricing context to calculate prices - region_id`
)
} catch (e) {
return next(e)
}
}
req.filterableFields.region_id = regionId
req.filterableFields.country_code = countryCode
req.filterableFields.province = province
return next()
}
}
View on GitHub (pinned to 5e06e544a2)
Solutions
- Create at least one region and set it as the store's default region (Admin > Settings > Regions, then set the store's default_region_id)
- Pass region_id explicitly: GET /store/products?region_id=reg_...
- Or pass cart_id so the middleware can take the region from the cart
Example fix
// before GET /store/products // after GET /store/products?region_id=reg_123
Defensive patterns
Strategy: validation
Validate before calling
// ensure a region before calling product listing
let regionId = cachedRegionId
if (!regionId) {
const { regions } = await sdk.store.region.list()
if (!regions.length) throw new Error('no regions configured')
regionId = regions[0].id
}
const products = await sdk.store.product.list({ region_id: regionId }) Try / catch
try {
await sdk.store.product.list()
} catch (e) {
if (e.type === 'invalid_data' && /region_id/.test(e.message)) {
// fetch regions and retry with an explicit region_id
}
throw e
} Prevention
- Always resolve and cache a region id client-side before rendering prices
- Ensure setup scripts create at least one region and set store.default_region_id
When it happens
Trigger: GET /store/products (or variants) without a region_id query param, without a cart_id whose cart has a region, and where the store associated with the publishable key lacks default_region_id. Occurs on fresh installs or stores created without a default region.
Common situations: New project where regions haven't been created/seeded yet; store record created without a default region; frontend not sending region_id after switching to region-based pricing.
Related errors
- Region with id ${req.filterableFields.region_id} not found w
- invalid_data
- Variants with IDs ${priceNotFound.join(", ")} do not have a
- NOT_ALLOWED
- Region with id: ${req.params.id} was not found
AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27).
Data as JSON: /api/errors/0badbb6f84127a21.
Report an issue: GitHub.