{"record":{"id":"ba366a72fee2cc14","repo":"medusajs/medusa","slug":"a-shipping-method-with-id-input-shipping-method","errorCode":null,"errorMessage":"A shipping method with id ${input.shipping_method_id} was not found","messagePattern":"A shipping method with id (.+?) was not found","errorType":"exception","errorClass":"MedusaError","httpStatus":400,"severity":"error","filePath":"packages/core/core-flows/src/draft-order/steps/update-draft-order-shipping-metod.ts","lineNumber":66,"sourceCode":"  updateDraftOrderShippingMethodStepId,\n  async function (\n    input: UpdateDraftOrderShippingMethodStepInput,\n    { container }\n  ) {\n    const service = container.resolve<IOrderModuleService>(Modules.ORDER)\n\n    const [beforeUpdate] = await service.listOrderShippingMethods(\n      {\n        id: input.shipping_method_id,\n      },\n      {\n        take: 1,\n        select: [\"id\", \"shipping_option_id\", \"amount\"],\n      }\n    )\n\n    if (!beforeUpdate) {\n      throw new MedusaError(\n        MedusaError.Types.INVALID_DATA,\n        `A shipping method with id ${input.shipping_method_id} was not found`\n      )\n    }\n\n    const [updatedMethod] = await service.updateOrderShippingMethods([\n      {\n        id: input.shipping_method_id,\n        shipping_option_id: input.shipping_option_id,\n        amount: input.amount,\n      },\n    ])\n\n    return new StepResponse(\n      {\n        before: beforeUpdate,\n        after: updatedMethod,\n      },","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/core/core-flows/src/draft-order/steps/update-draft-order-shipping-metod.ts#L48-L84","documentation":"updateDraftOrderShippingMethodStep looks up the shipping method by id before updating; if no order shipping method matches input.shipping_method_id, it throws. Note it uses INVALID_DATA although it is semantically a not-found.","triggerScenarios":"Calling the draft-order update-shipping-method workflow with a shipping_method_id that doesn't exist (or belongs to a different order).","commonSituations":"Stale UI passing an id from a previous draft version; shipping method already removed from the draft order; typo/truncated uuid; concurrent edit removed the method.","solutions":["Re-fetch the draft order's shipping methods and use a current id","Confirm the shipping method belongs to the same order before updating","Handle the error by refreshing the draft order state in the client"],"exampleFix":"// before\nawait updateDraftOrderShippingMethodWorkflow(container).run({\n  input: { order_id, shipping_method_id: oldId, data: { amount: 500 } },\n})\n\n// after: re-read current methods\nconst order = await query.graph({ entity: \"order\", filters: { id: order_id }, fields: [\"shipping_methods.*\"] })\nconst current = order.data[0].shipping_methods[0]\nawait updateDraftOrderShippingMethodWorkflow(container).run({\n  input: { order_id, shipping_method_id: current.id, data: { amount: 500 } },\n})","handlingStrategy":"validation","validationCode":"const methods = await service.listOrderShippingMethods({ id: input.shipping_method_id, order_id: input.order_id })\nif (!methods.length) throw new Error(\"Shipping method not on this order\")","typeGuard":null,"tryCatchPattern":"try { await workflow(scope).run({ input }) } catch (e) { if (/shipping method with id .* was not found/.test(e.message)) { /* refetch draft order methods, retry with current id */ } throw e }","preventionTips":["Always re-read shipping methods from the draft order before editing","Scope lookups by order_id, not just method id"],"tags":["draft-order","shipping-method","not-found"],"backgroundTag":"shipping-method-not-found","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}