medusajs/medusa · error · MedusaError

User with id: ${id} was not found

Error message

User with id: ${id} was not found

What it means

Thrown by GET /admin/users/:id when the remote query for the user returns no rows. Standard NOT_FOUND for a single-user fetch.

Source

Thrown at packages/medusa/src/api/admin/users/[id]/route.ts:34

import { refetchUser } from "../helpers"

// Get user
export const GET = async (
  req: AuthenticatedMedusaRequest<HttpTypes.AdminUserParams>,
  res: MedusaResponse<HttpTypes.AdminUserResponse>
) => {
  const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
  const { id } = req.params

  const query = remoteQueryObjectFromString({
    entryPoint: "user",
    variables: { id },
    fields: req.queryConfig.fields,
  })

  const [user] = await remoteQuery(query)
  if (!user) {
    throw new MedusaError(
      MedusaError.Types.NOT_FOUND,
      `User with id: ${id} was not found`
    )
  }

  res.status(200).json({ user })
}

// update user
export const POST = async (
  req: AuthenticatedMedusaRequest<
    HttpTypes.AdminUpdateUser,
    HttpTypes.AdminUserParams
  >,
  res: MedusaResponse<HttpTypes.AdminUserResponse>
) => {
  const workflow = updateUsersWorkflow(req.scope)

View on GitHub (pinned to 5e06e544a2)

Solutions

  1. List users via GET /admin/users to confirm the id
  2. Check whether the user was soft-deleted
  3. Ensure you pass the user id, not the auth identity id
Defensive patterns

Strategy: try-catch

Try / catch

try { const { user } = await medusa.admin.users.retrieve(id) } catch (e) { if (e.type === 'not_found') showNotFoundPage() else throw e }

Prevention

When it happens

Trigger: GET /admin/users/{id} with an unknown, deleted, or malformed id.

Common situations: Following a link to a deleted user profile; using an auth identity id instead of the user id.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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