{"record":{"id":"2345c6f0cefd9fcb","repo":"medusajs/medusa","slug":"service-zone-with-id-req-params-zone-id-not-fo-2345c6","errorCode":null,"errorMessage":"Service zone with id: ${req.params.zone_id} not found on fulfillment set","messagePattern":"Service zone with id: (.+?) not found on fulfillment set","errorType":"http","errorClass":"MedusaError","httpStatus":404,"severity":"error","filePath":"packages/medusa/src/api/admin/fulfillment-sets/[id]/service-zones/[zone_id]/route.ts","lineNumber":67,"sourceCode":"export const POST = async (\n  req: MedusaRequest<\n    HttpTypes.AdminUpdateFulfillmentSetServiceZone,\n    HttpTypes.AdminServiceZonesParams\n  >,\n  res: MedusaResponse<AdminFulfillmentSetResponse>\n) => {\n  const fulfillmentModuleService = req.scope.resolve<IFulfillmentModuleService>(\n    Modules.FULFILLMENT\n  )\n\n  // ensure fulfillment set exists and that the service zone is part of it\n  const fulfillmentSet = await fulfillmentModuleService.retrieveFulfillmentSet(\n    req.params.id,\n    { relations: [\"service_zones\"] }\n  )\n\n  if (!fulfillmentSet.service_zones.find((s) => s.id === req.params.zone_id)) {\n    throw new MedusaError(\n      MedusaError.Types.NOT_FOUND,\n      `Service zone with id: ${req.params.zone_id} not found on fulfillment set`\n    )\n  }\n\n  const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)\n\n  const workflowInput = {\n    selector: { id: req.params.zone_id },\n    update: req.validatedBody,\n  }\n\n  await updateServiceZonesWorkflow(req.scope).run({\n    input: workflowInput,\n  })\n\n  const [fulfillment_set] = await remoteQuery(\n    remoteQueryObjectFromString({","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/medusa/src/api/admin/fulfillment-sets/[id]/service-zones/[zone_id]/route.ts#L49-L85","documentation":"The POST (update) /admin/fulfillment-sets/:id/service-zones/:zone_id route retrieves the fulfillment set with its service_zones relation and checks that the zone is actually attached to that set; otherwise it throws NOT_FOUND (HTTP 404), since a zone id alone is not enough — it must belong to the set.","triggerScenarios":"POST updating a service zone whose id exists but is attached to a different fulfillment set; stale zone id after the zone was recreated under another set.","commonSituations":"Reusing zone ids across fulfillment sets (e.g. shipping profile migrations); updating zones after a set was rebuilt.","solutions":["Confirm the zone is listed under GET /admin/fulfillment-sets/:id before updating","Use the zone ids returned by that fulfillment set's own queries","If the zone moved sets, address it through its current parent set"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const set = await fulfillmentModuleService.retrieveFulfillmentSet(setId, { relations: [\"service_zones\"] })\nif (!set.service_zones.some((z) => z.id === zoneId)) {\n  throw new Error(`Zone ${zoneId} not attached to set ${setId}`)\n}","typeGuard":"const isZoneOfSet = (set: {service_zones:{id:string}[]}, zoneId: string) =>\n  set.service_zones.some((z) => z.id === zoneId)","tryCatchPattern":"try { await updateZone(setId, zoneId, payload) } catch (e) { if (e.statusCode === 404) { refetchSetAndZones(); retryWithCorrectIds() } else throw e }","preventionTips":["Keep set id and zone id paired from the same fetch","Re-verify ownership after zone moves between sets"],"tags":["admin-api","fulfillment","service-zones","ownership-check"],"backgroundTag":"http-404-nested-resource-not-found","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}