medusajs/medusa · error · MedusaError

No item found for order ${input.order_id} in order change ${

Error message

No item found for order ${input.order_id} in order change ${orderChange.id}

What it means

validateDraftOrderRemoveActionItemStep searches the order change's actions for input.action_id; if no action with that id exists on the change, it throws. It means the draft-order change action you are trying to remove is not part of the current pending change.

Source

Thrown at packages/core/core-flows/src/draft-order/steps/validate-draft-order-remove-action-item.ts:55

 *   },
 *   orderChange: {
 *     id: "orch_123",
 *     // other order change details...
 *   }
 * })
 */
export const validateDraftOrderRemoveActionItemStep = createStep(
  "validate-draft-order-remove-action-item",
  async function ({
    input,
    orderChange,
  }: ValidateDraftOrderUpdateActionItemStepInput) {
    const associatedAction = (orderChange.actions ?? []).find(
      (a) => a.id === input.action_id
    ) as OrderChangeActionDTO

    if (!associatedAction) {
      throw new MedusaError(
        MedusaError.Types.INVALID_DATA,
        `No item found for order ${input.order_id} in order change ${orderChange.id}`
      )
    }

    if (
      ![ChangeActionType.ITEM_ADD, ChangeActionType.ITEM_UPDATE].includes(
        associatedAction.action as ChangeActionType
      )
    ) {
      throw new MedusaError(
        MedusaError.Types.INVALID_DATA,
        `Action ${associatedAction.id} is not adding or updating an item`
      )
    }
  }
)

View on GitHub (pinned to 5e06e544a2)

Solutions

  1. Re-fetch the draft order change (order change actions) and use a live action_id
  2. Confirm the order change is still in pending status
  3. Refresh the admin UI state after confirm/delete operations

Example fix

// before
await removeItemDraftOrderWorkflow(container).run({ input: { order_id, action_id: staleId } })

// after
const changes = await query.graph({ entity: "order_change", filters: { order_id, status: "pending" }, fields: ["actions.*"] })
const action = changes.data[0]?.actions.find((a) => a.id === wantedId)
if (action) {
  await removeItemDraftOrderWorkflow(container).run({ input: { order_id, action_id: action.id } })
}
Defensive patterns

Strategy: validation

Validate before calling

const changes = await query.graph({ entity: "order_change", filters: { order_id, status: "pending" }, fields: ["actions.id"] })
const exists = changes.data[0]?.actions.some((a) => a.id === action_id)

Try / catch

try { await workflow(scope).run({ input }) } catch (e) { if (/No item found for order .* in order change/.test(e.message)) { /* refresh change actions in UI */ } throw e }

Prevention

When it happens

Trigger: Calling the draft-order remove-item (delete action) workflow with an action_id that is not among orderChange.actions (action already applied, change confirmed, or wrong order change).

Common situations: Draft order was already completed/confirmed so the pending change no longer holds that action; client holds a stale action id; action was removed by another admin session concurrently.

Related errors


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