medusajs/medusa · error · MedusaError
Region with id: ${req.params.id} was not found
Error message
Region with id: ${req.params.id} was not found What it means
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.
Source
Thrown at packages/medusa/src/api/store/regions/[id]/route.ts:25
import { HttpTypes } from "@medusajs/framework/types"
export const GET = async (
req: MedusaRequest<HttpTypes.StoreGetRegionParams>,
res: MedusaResponse<HttpTypes.StoreRegionResponse>
) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
const queryObject = remoteQueryObjectFromString({
entryPoint: "region",
variables: {
filters: { id: req.params.id },
},
fields: req.queryConfig.fields,
})
const [region] = await remoteQuery(queryObject)
if (!region) {
throw new MedusaError(
MedusaError.Types.NOT_FOUND,
`Region with id: ${req.params.id} was not found`
)
}
res.status(200).json({ region })
}
View on GitHub (pinned to 5e06e544a2)
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
Example fix
// before
const { region } = await sdk.store.region.retrieve(process.env.DEFAULT_REGION_ID!)
// after
const { regions } = await sdk.store.region.list()
const region = regions.find((r) => r.id === wantedId) ?? regions[0] Defensive patterns
Strategy: fallback
Validate before calling
const { regions } = await sdk.store.region.list()
const region = regions.find((r) => r.id === wantedId) ?? regions[0]
if (!region) throw new Error('No regions configured') Try / catch
try {
const { region } = await sdk.store.region.retrieve(id)
} catch (e: any) {
if (e.type === 'not_found') return pickDefaultRegion()
throw e
} Prevention
- 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
When it happens
Trigger: Requesting /store/regions/reg_... with a nonexistent or deleted region id; also when a cached/default region id is used after regions were restructured.
Common situations: 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.
Related errors
- Region with id ${req.filterableFields.region_id} not found w
- 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/69e44de076150985.
Report an issue: GitHub.