{"record":{"id":"d832b016523c3392","repo":"medusajs/medusa","slug":"customer-group-with-id-req-params-id-not-foun","errorCode":null,"errorMessage":"Customer group with id \"${req.params.id}\" not found","messagePattern":"Customer group with id \"(.+?)\" not found","errorType":"http","errorClass":"MedusaError","httpStatus":404,"severity":"error","filePath":"packages/medusa/src/api/admin/customer-groups/[id]/route.ts","lineNumber":47,"sourceCode":"  }\n\n  res.status(200).json({ customer_group: customerGroup })\n}\n\nexport const POST = async (\n  req: AuthenticatedMedusaRequest<\n    HttpTypes.AdminUpdateCustomerGroup,\n    HttpTypes.SelectParams\n  >,\n  res: MedusaResponse<HttpTypes.AdminCustomerGroupResponse>\n) => {\n  const existingCustomerGroup = await refetchCustomerGroup(\n    req.params.id,\n    req.scope,\n    [\"id\"]\n  )\n  if (!existingCustomerGroup) {\n    throw new MedusaError(\n      MedusaError.Types.NOT_FOUND,\n      `Customer group with id \"${req.params.id}\" not found`\n    )\n  }\n\n  await updateCustomerGroupsWorkflow(req.scope).run({\n    input: {\n      selector: { id: req.params.id },\n      update: req.validatedBody,\n    },\n  })\n\n  const customerGroup = await refetchCustomerGroup(\n    req.params.id,\n    req.scope,\n    req.queryConfig.fields\n  )\n  res.status(200).json({ customer_group: customerGroup })","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/medusa/src/api/admin/customer-groups/[id]/route.ts#L29-L65","documentation":"The POST (update) /admin/customer-groups/:id route refetches the group by id before delegating to updateCustomerGroupsWorkflow; a missing group throws NOT_FOUND (HTTP 404).","triggerScenarios":"POST /admin/customer-groups/:id with update payload for a nonexistent group id.","commonSituations":"Concurrent deletion by another admin; automation scripts with cached group ids.","solutions":["Check existence with GET /admin/customer-groups/:id before update","Refresh group ids in scripts after delete operations","Surface 404 as 'group no longer exists' in UI instead of a generic error"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const exists = (await sdk.admin.customerGroup.list({ id })).customer_groups.length > 0\nif (!exists) throw new Error(\"group deleted before update\")","typeGuard":"null","tryCatchPattern":"try { await updateGroup(id, payload) } catch (e) { if (e.statusCode === 404) { reloadGroups(); alertUser() } else throw e }","preventionTips":["Scripts should re-list groups before each mutation","UIs should disable save for stale records"],"tags":["admin-api","customer-groups","update","not-found"],"backgroundTag":"http-404-update-missing-resource","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}