medusajs/medusa · error · MedusaError

Action ${associatedAction.id} is not adding an item

Error message

Action ${associatedAction.id} is not adding an item

What it means

Second phase of validate-draft-order-update-action-item: the action exists but is not an ITEM_ADD action, so its quantity/details cannot be edited through the add-item update workflow.

Source

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

export const validateDraftOrderUpdateActionItemStep = createStep(
  "validate-draft-order-update-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 request to add item for order ${input.order_id} in order change ${orderChange.id}`
      )
    }

    if (associatedAction.action !== ChangeActionType.ITEM_ADD) {
      throw new MedusaError(
        MedusaError.Types.INVALID_DATA,
        `Action ${associatedAction.id} is not adding an item`
      )
    }
  }
)

View on GitHub (pinned to 5e06e544a2)

Solutions

  1. Verify action.action === 'ITEM_ADD' before calling this workflow
  2. Use the edit-order-update-item workflow for ITEM_UPDATE actions
  3. Filter the actions list by type in the client

Example fix

// before
await updateDraftOrderUpdateItemActionWorkflow(container).run({ input: { order_id, action_id, data: { quantity: 3 } } }) // action is ITEM_UPDATE

// after
if (action.action === "ITEM_ADD") {
  await updateDraftOrderUpdateItemActionWorkflow(container).run({ input: { order_id, action_id: action.id, data: { quantity: 3 } } })
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (action.action !== "ITEM_ADD") throw new Error("Only ITEM_ADD actions editable here")

Type guard

const isItemAddAction = (a: { action: string }) => a.action === "ITEM_ADD"

Prevention

When it happens

Trigger: Passing an ITEM_UPDATE or SHIPPING_ADD action id to updateDraftOrderUpdateItemActionWorkflow which only accepts ITEM_ADD actions.

Common situations: UI reuses one edit handler for all action types; misunderstanding that this workflow edits pending add-item requests only.

Related errors


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