[Bug]: Confirming a claim or exchange without an outbound shipping method reserves no inventory for the replacement items
Package.json file
{
"dependencies": {
"@medusajs/admin-sdk": "2.19.0",
"@medusajs/cli": "2.19.0",
"@medusajs/framework": "2.19.0",
"@medusajs/medusa": "2.19.0"
}
}(Resolved: @medusajs/core-flows 2.19.0, @medusajs/dashboard 2.19.0. The code below is unchanged on develop at 62a5200, and the permalinks point there.)
Node.js version
v22.22.2
Database and its version
PostgreSQL 17.11
Operating system name and version
Ubuntu 24.04.2 LTS
Browser name
n/a (server-side; also reproduced through the admin dashboard)
What happended?
Confirming a claim or exchange that has no outbound shipping method reserves no inventory for its outbound (replacement) items. The confirm succeeds and there is no error or warning. From that point on:
available_quantitystill counts the replacement units as on the shelf, so they can be sold again, and- the replacement lines cannot be fulfilled:
createOrderFulfillmentWorkflowrefuses withNo stock reservation found for item ….
The admin dashboard makes this one click away. outbound_option_id is z.string().nullish() in the exchange/claim create form schema, and the Confirm button has no disabled condition, so an operator can confirm without choosing an outbound shipping method.
Cause
In both confirm workflows, the reservation sits inside when({ claimShippingMethod }) / when({ exchangeShippingMethod }), but nothing in that branch uses the shipping method:
The condition looks like a leftover. Before #8448 ("manage inventory reservation of claims and exchanges"), that branch created the outbound fulfillment and needed the shipping option for it (claimShippingOption → createFulfillmentWorkflow). #8448 replaced the fulfillment with reserveInventoryStep and removed the shipping-option lookup, but left the when(shippingMethod) guard. So a reservation, which is a fact about inventory, now depends on whether a shipping method was picked.
Cart completion, convertDraftOrderWorkflow and confirmOrderEditRequestWorkflow all reserve unconditionally. Only claims and exchanges have this dependency.
Expected behavior
Confirming a claim or exchange reserves its outbound items whether or not an outbound shipping method is set. Alternatively, it refuses to confirm without one, and the dashboard says so before the operator confirms.
Reserving unconditionally seems right: stock leaves the building either way, and the later fulfillment already falls back to the order's shipping method (input.shipping_option_id ?? order.shipping_methods[0]). Moving reserveInventoryStep (and its query) out of the when is enough; the shipping method is not an input to it.
Actual behavior
Measured over the admin API. The inventory item holds 25 available, and the order has one fulfilled line. A claim (or exchange) is created with outbound items 13 × Piece + 1 × Carton-of-12 = 25 units, and no outbound shipping method:
before confirm {"stocked":25,"reserved":0,"available":25}
POST /admin/claims/:id/request -> 200
after confirm {"stocked":25,"reserved":0,"available":25} <- nothing reserved
POST /admin/orders/:id/fulfillments (replacement lines)
-> 400 No stock reservation found for item ordli_… (Piece)The same flow with an outbound shipping method set reserves 25 (reserved: 25, available: 0), and the fulfillment then succeeds. The exchange flow behaves identically.
Link to reproduction repo
No public repo. Steps with the admin API on a fresh 2.19.0 project:
- Create a placed order with one line and fulfill it.
POST /admin/claims{ order_id, type: "replace" }, thenPOST /admin/claims/:id/claim-itemsfor that line. For an exchange:POST /admin/exchanges, thenPOST /admin/exchanges/:id/inbound/items.POST /admin/claims/:id/outbound/itemswith any stocked variant. Do not call…/outbound/shipping-method.POST /admin/claims/:id/request, thenGET /admin/reservations?inventory_item_id=…returns[].- Fulfilling the replacement line fails with
No stock reservation found.
Source: medusajs/medusa