Skip to content

[Bug]: Draft order detail page crashes with 404 error (User with id: apk_01M0Z6297SC580MRQE3G9HCG4B was not found) #16775

Description

@timhonders

Package.json file

"dependencies": {
  "@medusajs/admin-sdk": "2.19.0",
  "@medusajs/admin-shared": "2.19.0",
  "@medusajs/caching": "2.19.0",
  "@medusajs/cli": "2.19.0",
  "@medusajs/dashboard": "2.19.0",
  "@medusajs/draft-order": "2.19.0",
  "@medusajs/framework": "2.19.0",
  "@medusajs/medusa": "2.19.0",
  "@medusajs/ui": "4.2.1",
  "@tanstack/react-query": "5.64.2",
  "react-i18next": "13.5.0",
  "react-router-dom": "7.18.2",
  "zod": "4.2.0"
}

Node.js version

v24.11.0

Database and its version

Postgres (Cloud)

Operating system name and version

Cloud

Browser name

No response

What happended?

For a POS System we are creating/editing a draftOrder, using the admin api with admin api key.

When u go to the drafOrder detail page it crashes with the message: User with id: apk_01M0.............E3G9HCG4B was not found

in file packages/plugins/draft-order/src/admin/components/draft-orders/activity-section.tsx on line 126 the 404 error is thrown

const { user, isPending, isError, error } = useUser(item.userId!, undefined, {
  enabled: !!item.userId,
})

if (isError) {
  throw error
}

it tries to fetch a user with the apk_ id witch doesn't exist

Steps to reproduce

  1. Create a secret admin API key and point the JS SDK at it:

    const medusa = new Medusa({
      baseUrl: "http://localhost:9000",
      apiKey: "sk_…",
    })
  2. Create a draft order, then edit it:

    await medusa.admin.draftOrder.beginEdit(draftOrderId)
    await medusa.admin.draftOrder.addItems(draftOrderId, {
      items: [{ variant_id: variantId, quantity: 1 }],
    })
    await medusa.admin.draftOrder.confirmEdit(draftOrderId)
  3. Open that draft order in the admin dashboard. The page fails to render.

Expected behavior

Show activity "By Api user" or other message.

Actual behavior

draftOrder detail page crashes

Link to reproduction repo

no url

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions