medusajs/medusa · error · MedusaError
Customer group with id "${req.params.id}" not found
Error message
Customer group with id "${req.params.id}" not found What it means
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).
Source
Thrown at packages/medusa/src/api/admin/customer-groups/[id]/route.ts:47
}
res.status(200).json({ customer_group: customerGroup })
}
export const POST = async (
req: AuthenticatedMedusaRequest<
HttpTypes.AdminUpdateCustomerGroup,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminCustomerGroupResponse>
) => {
const existingCustomerGroup = await refetchCustomerGroup(
req.params.id,
req.scope,
["id"]
)
if (!existingCustomerGroup) {
throw new MedusaError(
MedusaError.Types.NOT_FOUND,
`Customer group with id "${req.params.id}" not found`
)
}
await updateCustomerGroupsWorkflow(req.scope).run({
input: {
selector: { id: req.params.id },
update: req.validatedBody,
},
})
const customerGroup = await refetchCustomerGroup(
req.params.id,
req.scope,
req.queryConfig.fields
)
res.status(200).json({ customer_group: customerGroup })View on GitHub (pinned to 5e06e544a2)
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
Defensive patterns
Strategy: validation
Validate before calling
const exists = (await sdk.admin.customerGroup.list({ id })).customer_groups.length > 0
if (!exists) throw new Error("group deleted before update") Type guard
null
Try / catch
try { await updateGroup(id, payload) } catch (e) { if (e.statusCode === 404) { reloadGroups(); alertUser() } else throw e } Prevention
- Scripts should re-list groups before each mutation
- UIs should disable save for stale records
When it happens
Trigger: POST /admin/customer-groups/:id with update payload for a nonexistent group id.
Common situations: Concurrent deletion by another admin; automation scripts with cached group ids.
Related errors
- Campaign with id "${req.params.id}" not found
- Customer group with id: ${req.params.id} not found
- Customer with id "${req.params.id}" not found
- Campaign with id: ${req.params.id} was not found
- Claim with id: ${req.params.id} was not found
AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27).
Data as JSON: /api/errors/d832b016523c3392.
Report an issue: GitHub.