{"record":{"id":"529eb3fc1205fddb","repo":"medusajs/medusa","slug":"no-item-found-for-order-input-order-id-in-order","errorCode":null,"errorMessage":"No item found for order ${input.order_id} in order change ${orderChange.id}","messagePattern":"No item found for order (.+?) in order change (.+?)","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":55,"sourceCode":" *   },\n *   orderChange: {\n *     id: \"orch_123\",\n *     // other order change details...\n *   }\n * })\n */\nexport const validateDraftOrderRemoveActionItemStep = createStep(\n  \"validate-draft-order-remove-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 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":37,"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#L37-L73","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Re-fetch the draft order change (order change actions) and use a live action_id","Confirm the order change is still in pending status","Refresh the admin UI state after confirm/delete operations"],"exampleFix":"// before\nawait removeItemDraftOrderWorkflow(container).run({ input: { order_id, action_id: staleId } })\n\n// after\nconst changes = await query.graph({ entity: \"order_change\", filters: { order_id, status: \"pending\" }, fields: [\"actions.*\"] })\nconst action = changes.data[0]?.actions.find((a) => a.id === wantedId)\nif (action) {\n  await removeItemDraftOrderWorkflow(container).run({ input: { order_id, action_id: action.id } })\n}","handlingStrategy":"validation","validationCode":"const changes = await query.graph({ entity: \"order_change\", filters: { order_id, status: \"pending\" }, fields: [\"actions.id\"] })\nconst exists = changes.data[0]?.actions.some((a) => a.id === action_id)","typeGuard":null,"tryCatchPattern":"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 }","preventionTips":["Refetch pending order change actions before removals","Disable removal buttons for actions already confirmed"],"tags":["draft-order","order-change","action","not-found"],"backgroundTag":"order-change-action-not-found","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}