medusajs/medusa · error · MedusaError

NOT_FOUND

NOT_FOUND

Error message

Customer with id: ${id} was not found

What it means

Thrown by GET /store/customers/me when the customer id resolved from the authenticated session (auth_context.actor_id) does not correspond to an existing customer in the database. The route refetches the customer with the requested fields and throws NOT_FOUND when the lookup returns nothing. This almost always means the auth token/session references a customer that was deleted (e.g. soft-deleted) after the token was issued.

Source

Thrown at packages/medusa/src/api/store/customers/me/route.ts:18

import {
  AuthenticatedMedusaRequest,
  MedusaResponse,
} from "@medusajs/framework/http"
import { refetchCustomer } from "../helpers"
import { MedusaError } from "@medusajs/framework/utils"
import { updateCustomersWorkflow } from "@medusajs/core-flows"
import { HttpTypes } from "@medusajs/framework/types"

export const GET = async (
  req: AuthenticatedMedusaRequest<HttpTypes.StoreGetCustomerParams>,
  res: MedusaResponse<HttpTypes.StoreCustomerResponse>
) => {
  const id = req.auth_context.actor_id
  const customer = await refetchCustomer(id, req.scope, req.queryConfig.fields)

  if (!customer) {
    throw new MedusaError(
      MedusaError.Types.NOT_FOUND,
      `Customer with id: ${id} was not found`
    )
  }

  res.json({ customer })
}

export const POST = async (
  req: AuthenticatedMedusaRequest<
    HttpTypes.StoreUpdateCustomer,
    HttpTypes.SelectParams
  >,
  res: MedusaResponse<HttpTypes.StoreCustomerResponse>
) => {
  const customerId = req.auth_context.actor_id
  await updateCustomersWorkflow(req.scope).run({
    input: {

View on GitHub (pinned to 5e06e544a2)

Solutions

  1. Log the customer out and re-authenticate to get a fresh token whose actor_id points to an existing customer
  2. Verify the customer still exists (admin: GET /admin/customers/:id) and restore/reactivate it if soft-deleted
  3. Check your auth provider setup so the actor_id is correctly linked to the customer entity
  4. If tokens are long-lived, shorten their lifetime or revoke them on customer deletion

Example fix

// before
const { customer } = await sdk.store.customer.retrieve() // 404 after account deletion

// after
try {
  const { customer } = await sdk.store.customer.retrieve()
} catch (e) {
  if (e.type === 'not_found') {
    await sdk.auth.logout()
    redirect('/login?reason=session-expired')
  }
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Refresh session before use
const { customer } = await sdk.auth.me() // or re-authenticate
if (!customer) await sdk.auth.logout()

Try / catch

try {
  const { customer } = await sdk.store.customer.retrieve()
} catch (e: any) {
  if (e.type === 'not_found' && e.message.includes('Customer')) {
    await sdk.auth.logout()
    window.location.href = '/login'
  } else throw e
}

Prevention

When it happens

Trigger: Calling GET /store/customers/me with a valid customer JWT/session whose actor_id was deleted, or after the customer record was removed via Admin API while the store client kept its access token. Also occurs if the auth identity is misconfigured so actor_id points at a wrong/nonexistent record.

Common situations: Deleted test customers while the storefront kept cached tokens; importing customers and having stale sessions; auth provider misconfiguration producing actor_ids that don't match the customer table.

Related errors


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