{"record":{"id":"9a15fbcfd925de49","repo":"medusajs/medusa","slug":"action-associatedaction-id-is-not-adding-an-ite","errorCode":null,"errorMessage":"Action ${associatedAction.id} is not adding an item","messagePattern":"Action (.+?) is not adding an item","errorType":"exception","errorClass":"MedusaError","httpStatus":400,"severity":"error","filePath":"packages/core/core-flows/src/draft-order/steps/validate-draft-order-update-action-item.ts","lineNumber":62,"sourceCode":"export const validateDraftOrderUpdateActionItemStep = createStep(\n  \"validate-draft-order-update-action-item\",\n  async function ({\n    input,\n    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 request to add item for order ${input.order_id} in order change ${orderChange.id}`\n      )\n    }\n\n    if (associatedAction.action !== ChangeActionType.ITEM_ADD) {\n      throw new MedusaError(\n        MedusaError.Types.INVALID_DATA,\n        `Action ${associatedAction.id} is not adding an item`\n      )\n    }\n  }\n)\n","sourceCodeStart":44,"sourceCodeEnd":69,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/core/core-flows/src/draft-order/steps/validate-draft-order-update-action-item.ts#L44-L69","documentation":"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.","triggerScenarios":"Passing an ITEM_UPDATE or SHIPPING_ADD action id to updateDraftOrderUpdateItemActionWorkflow which only accepts ITEM_ADD actions.","commonSituations":"UI reuses one edit handler for all action types; misunderstanding that this workflow edits pending add-item requests only.","solutions":["Verify action.action === 'ITEM_ADD' before calling this workflow","Use the edit-order-update-item workflow for ITEM_UPDATE actions","Filter the actions list by type in the client"],"exampleFix":"// before\nawait updateDraftOrderUpdateItemActionWorkflow(container).run({ input: { order_id, action_id, data: { quantity: 3 } } }) // action is ITEM_UPDATE\n\n// after\nif (action.action === \"ITEM_ADD\") {\n  await updateDraftOrderUpdateItemActionWorkflow(container).run({ input: { order_id, action_id: action.id, data: { quantity: 3 } } })\n}","handlingStrategy":"type-guard","validationCode":"if (action.action !== \"ITEM_ADD\") throw new Error(\"Only ITEM_ADD actions editable here\")","typeGuard":"const isItemAddAction = (a: { action: string }) => a.action === \"ITEM_ADD\"","tryCatchPattern":null,"preventionTips":["Use the order-edit item workflow for ITEM_UPDATE actions"],"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"}