{"record":{"id":"399a706a0e0831f6","repo":"medusajs/medusa","slug":"action-associatedaction-id-is-not-adding-or-upd","errorCode":null,"errorMessage":"Action ${associatedAction.id} is not adding or updating an item","messagePattern":"Action (.+?) is not adding or updating an item","errorType":"exception","errorClass":"MedusaError","httpStatus":400,"severity":"error","filePath":"packages/core/core-flows/src/draft-order/steps/validate-draft-order-remove-action-item.ts","lineNumber":66,"sourceCode":"    orderChange,\n  }: ValidateDraftOrderUpdateActionItemStepInput) {\n    const associatedAction = (orderChange.actions ?? []).find(\n      (a) => a.id === input.action_id\n    ) as OrderChangeActionDTO\n\n    if (!associatedAction) {\n      throw new MedusaError(\n        MedusaError.Types.INVALID_DATA,\n        `No item found for order ${input.order_id} in order change ${orderChange.id}`\n      )\n    }\n\n    if (\n      ![ChangeActionType.ITEM_ADD, ChangeActionType.ITEM_UPDATE].includes(\n        associatedAction.action as ChangeActionType\n      )\n    ) {\n      throw new MedusaError(\n        MedusaError.Types.INVALID_DATA,\n        `Action ${associatedAction.id} is not adding or updating an item`\n      )\n    }\n  }\n)\n","sourceCodeStart":48,"sourceCodeEnd":73,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/core/core-flows/src/draft-order/steps/validate-draft-order-remove-action-item.ts#L48-L73","documentation":"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.","triggerScenarios":"Passing an action_id whose ChangeActionType is e.g. SHIPPING_ADD, SHIPPING_REMOVE, or WRITE_OFF items to the draft-order remove-item workflow.","commonSituations":"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.","solutions":["Filter the order change actions by action === 'ITEM_ADD' or 'ITEM_UPDATE' before offering removal","Use the shipping-method removal workflow for SHIPPING_* actions","Re-fetch and display action types in the client"],"exampleFix":"// before\nawait removeItemDraftOrderWorkflow(container).run({ input: { order_id, action_id } }) // action is SHIPPING_ADD\n\n// after\nif ([\"ITEM_ADD\", \"ITEM_UPDATE\"].includes(action.action)) {\n  await removeItemDraftOrderWorkflow(container).run({ input: { order_id, action_id: action.id } })\n} else {\n  await removeDraftOrderShippingMethodWorkflow(container).run({ input: { order_id, action_id: action.id } })\n}","handlingStrategy":"type-guard","validationCode":"const valid = [\"ITEM_ADD\", \"ITEM_UPDATE\"]\nif (!valid.includes(action.action)) throw new Error(\"Not a removable item action\")","typeGuard":"const isItemAction = (a: { action: string }) => a.action === \"ITEM_ADD\" || a.action === \"ITEM_UPDATE\"","tryCatchPattern":null,"preventionTips":["Display action type in the admin UI and route removals accordingly","Filter action lists by type client-side"],"tags":["draft-order","order-change","action-type"],"backgroundTag":"invalid-order-change-action-type","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}