medusajs/medusa · error · MedusaError

Action ${associatedAction.id} is not adding or updating an i

Error message

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

What it means

Same draft-order removal validation, second phase: the found action exists but its action type is neither ITEM_ADD nor ITEM_UPDATE, so it cannot be removed as an item action.

Source

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

    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. Filter the order change actions by action === 'ITEM_ADD' or 'ITEM_UPDATE' before offering removal
  2. Use the shipping-method removal workflow for SHIPPING_* actions
  3. Re-fetch and display action types in the client

Example fix

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

// after
if (["ITEM_ADD", "ITEM_UPDATE"].includes(action.action)) {
  await removeItemDraftOrderWorkflow(container).run({ input: { order_id, action_id: action.id } })
} else {
  await removeDraftOrderShippingMethodWorkflow(container).run({ input: { order_id, action_id: action.id } })
}
Defensive patterns

Strategy: type-guard

Validate before calling

const valid = ["ITEM_ADD", "ITEM_UPDATE"]
if (!valid.includes(action.action)) throw new Error("Not a removable item action")

Type guard

const isItemAction = (a: { action: string }) => a.action === "ITEM_ADD" || a.action === "ITEM_UPDATE"

Prevention

When it happens

Trigger: Passing an action_id whose ChangeActionType is e.g. SHIPPING_ADD, SHIPPING_REMOVE, or WRITE_OFF items to the draft-order remove-item workflow.

Common situations: UI mixes item actions and shipping actions in one list and routes removal to the wrong workflow; stale action list where types changed; custom code assuming all actions are item actions.

Related errors


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