{"record":{"id":"69e44de076150985","repo":"medusajs/medusa","slug":"region-with-id-req-params-id-was-not-found","errorCode":null,"errorMessage":"Region with id: ${req.params.id} was not found","messagePattern":"Region with id: (.+?) was not found","errorType":"http","errorClass":"MedusaError","httpStatus":404,"severity":"error","filePath":"packages/medusa/src/api/store/regions/[id]/route.ts","lineNumber":25,"sourceCode":"import { HttpTypes } from \"@medusajs/framework/types\"\n\nexport const GET = async (\n  req: MedusaRequest<HttpTypes.StoreGetRegionParams>,\n  res: MedusaResponse<HttpTypes.StoreRegionResponse>\n) => {\n  const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)\n  const queryObject = remoteQueryObjectFromString({\n    entryPoint: \"region\",\n    variables: {\n      filters: { id: req.params.id },\n    },\n    fields: req.queryConfig.fields,\n  })\n\n  const [region] = await remoteQuery(queryObject)\n\n  if (!region) {\n    throw new MedusaError(\n      MedusaError.Types.NOT_FOUND,\n      `Region with id: ${req.params.id} was not found`\n    )\n  }\n\n  res.status(200).json({ region })\n}\n","sourceCodeStart":7,"sourceCodeEnd":33,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/medusa/src/api/store/regions/[id]/route.ts#L7-L33","documentation":"Thrown by GET /store/regions/:id when the remote query for the region id returns no region. The id is invalid or the region was deleted. Returns 404 NOT_FOUND.","triggerScenarios":"Requesting /store/regions/reg_... with a nonexistent or deleted region id; also when a cached/default region id is used after regions were restructured.","commonSituations":"Storefront hardcodes or caches a default region id that was later deleted; region consolidation left stale ids in cookies or env vars; multi-region setups after data migration.","solutions":["List available regions via GET /store/regions and use a valid id","Update any hardcoded or cached default region id (env var, cookie, config) after region changes","Bootstrap region selection dynamically (e.g. first region or geo-based) instead of hardcoding"],"exampleFix":"// before\nconst { region } = await sdk.store.region.retrieve(process.env.DEFAULT_REGION_ID!)\n\n// after\nconst { regions } = await sdk.store.region.list()\nconst region = regions.find((r) => r.id === wantedId) ?? regions[0]","handlingStrategy":"fallback","validationCode":"const { regions } = await sdk.store.region.list()\nconst region = regions.find((r) => r.id === wantedId) ?? regions[0]\nif (!region) throw new Error('No regions configured')","typeGuard":null,"tryCatchPattern":"try {\n  const { region } = await sdk.store.region.retrieve(id)\n} catch (e: any) {\n  if (e.type === 'not_found') return pickDefaultRegion()\n  throw e\n}","preventionTips":["Never hardcode region ids; resolve dynamically","Update default-region env/cookie after region migrations","Cache the region list and fall back to the first region"],"tags":["store-api","region","not-found"],"backgroundTag":"resource-not-found-by-id","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}