{"record":{"id":"0badbb6f84127a21","repo":"medusajs/medusa","slug":"missing-required-pricing-context-to-calculate-pric","errorCode":null,"errorMessage":"Missing required pricing context to calculate prices - region_id","messagePattern":"Missing required pricing context to calculate prices - region_id","errorType":"validation","errorClass":"MedusaError","httpStatus":400,"severity":"error","filePath":"packages/medusa/src/api/utils/middlewares/products/normalize-data-for-context.ts","lineNumber":95,"sourceCode":"\n    // Finally, try to get it from the store defaults if not available\n    if (!regionId) {\n      const { data: stores } = await refetchEntities({\n        entity: \"store\",\n        scope: req.scope,\n        fields: [\"id\", \"default_region_id\"],\n        options: {\n          cache: {\n            enable: true,\n          },\n        },\n      })\n      regionId = stores[0]?.default_region_id\n    }\n\n    if (!regionId) {\n      try {\n        throw new MedusaError(\n          MedusaError.Types.INVALID_DATA,\n          `Missing required pricing context to calculate prices - region_id`\n        )\n      } catch (e) {\n        return next(e)\n      }\n    }\n\n    req.filterableFields.region_id = regionId\n    req.filterableFields.country_code = countryCode\n    req.filterableFields.province = province\n\n    return next()\n  }\n}\n","sourceCodeStart":77,"sourceCodeEnd":111,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/medusa/src/api/utils/middlewares/products/normalize-data-for-context.ts#L77-L111","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nGET /store/products\n\n// after\nGET /store/products?region_id=reg_123","handlingStrategy":"validation","validationCode":"// ensure a region before calling product listing\nlet regionId = cachedRegionId\nif (!regionId) {\n  const { regions } = await sdk.store.region.list()\n  if (!regions.length) throw new Error('no regions configured')\n  regionId = regions[0].id\n}\nconst products = await sdk.store.product.list({ region_id: regionId })","typeGuard":null,"tryCatchPattern":"try {\n  await sdk.store.product.list()\n} catch (e) {\n  if (e.type === 'invalid_data' && /region_id/.test(e.message)) {\n    // fetch regions and retry with an explicit region_id\n  }\n  throw e\n}","preventionTips":["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"],"tags":["pricing","region","store-api","configuration"],"backgroundTag":"missing-pricing-context","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}