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 GET /admin/customer-groups/:id route refetches the customer group via remote query and throws NOT_FOUND (HTTP 404) when the id does not match any group.

Source

Thrown at packages/medusa/src/api/admin/customer-groups/[id]/route.ts:25

  MedusaResponse,
} from "@medusajs/framework/http"

import { MedusaError } from "@medusajs/framework/utils"
import { refetchCustomerGroup } from "../helpers"
import { HttpTypes } from "@medusajs/framework/types"

export const GET = async (
  req: AuthenticatedMedusaRequest<HttpTypes.SelectParams>,
  res: MedusaResponse<HttpTypes.AdminCustomerGroupResponse>
) => {
  const customerGroup = await refetchCustomerGroup(
    req.params.id,
    req.scope,
    req.queryConfig.fields
  )

  if (!customerGroup) {
    throw new MedusaError(
      MedusaError.Types.NOT_FOUND,
      `Customer group with id: ${req.params.id} not found`
    )
  }

  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,

View on GitHub (pinned to 5e06e544a2)

Solutions

  1. List groups via GET /admin/customer-groups to confirm the id
  2. Handle 404 by routing back to the groups list
  3. Verify backend URL/environment
Defensive patterns

Strategy: try-catch

Validate before calling

const { customer_groups } = await sdk.admin.customerGroup.list({ id })
if (!customer_groups.length) throw new Error("group not found")

Type guard

null

Try / catch

try { await getGroup(id) } catch (e) { if (e.statusCode === 404) navigate("/customer-groups") else throw e }

Prevention

When it happens

Trigger: GET /admin/customer-groups/:id with a deleted or nonexistent group id.

Common situations: Group deleted while its detail page was open; stale links from notifications; environment mismatch.

Related errors


AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27). Data as JSON: /api/errors/be33f174c8c43551. Report an issue: GitHub.