medusajs/medusa · error · MedusaError

User ID not found

Error message

User ID not found

What it means

Thrown by GET /admin/users/me when the auth context carries no actor_id. Indicates the request is authenticated but not linked to a user actor.

Source

Thrown at packages/medusa/src/api/admin/users/me/route.ts:20

  AuthenticatedMedusaRequest,
  MedusaResponse,
} from "@medusajs/framework/http"
import { HttpTypes } from "@medusajs/framework/types"
import {
  ContainerRegistrationKeys,
  MedusaError,
  remoteQueryObjectFromString,
} from "@medusajs/framework/utils"

export const GET = async (
  req: AuthenticatedMedusaRequest<HttpTypes.AdminUserParams>,
  res: MedusaResponse<HttpTypes.AdminUserResponse>
) => {
  const id = req.auth_context.actor_id
  const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)

  if (!id) {
    throw new MedusaError(MedusaError.Types.NOT_FOUND, `User ID not found`)
  }

  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 })

View on GitHub (pinned to 5e06e544a2)

Solutions

  1. Ensure the auth identity is associated with a user (complete registration/login flow)
  2. Re-issue the token after the user is created and linked
  3. Check custom auth provider callbacks set actor_id correctly
Defensive patterns

Strategy: try-catch

Type guard

const hasActorId = (ctx: {actor_id?: string|null}): ctx is {actor_id: string} => typeof ctx.actor_id === 'string' && ctx.actor_id.length > 0

Try / catch

catch (e) { if (e.type === 'not_found') forceReauth() }

Prevention

When it happens

Trigger: Calling /admin/users/me with a token whose auth_context has no actor_id (e.g. a third-party service token or incomplete auth registration).

Common situations: Using a JWT minted before the user was fully registered; authenticating with a provider that created an auth identity but no user; custom auth flows that skip actor linking.

Related errors


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