medusajs/medusa · error · MedusaError
insufficient_inventory
insufficient_inventory
Error message
Some variant does not have the required inventory
What it means
The Redis engine's getRunningTransaction requires the workflow id to resolve the flow definition. A falsy workflowId throws a plain Error 'Workflow ID is required' before any lookup.
Source
Thrown at packages/core/core-flows/src/cart/steps/confirm-inventory.ts:92
// TODO: Should be bulk
const promises = data.items.map(async (item) => {
if (item.allow_backorder) {
return true
}
const itemQuantity = MathBN.mult(item.quantity, item.required_quantity)
return await inventoryService.confirmInventory(
item.inventory_item_id,
item.location_ids,
itemQuantity
)
})
const inventoryCoverage = await promiseAll(promises)
if (inventoryCoverage.some((hasCoverage) => !hasCoverage)) {
throw new MedusaError(
MedusaError.Types.NOT_ALLOWED,
`Some variant does not have the required inventory`,
MedusaError.Codes.INSUFFICIENT_INVENTORY
)
}
return new StepResponse(null)
}
)
View on GitHub (pinned to 5e06e544a2)
Solutions
- Validate workflowId presence before calling
- Default to the known workflow id from your own constants
- Return 400 from HTTP layers early
Example fix
// before
const tx = await engine.getRunningTransaction(req.query.wf, req.query.tx)
// after
const { wf, tx } = req.query
if (!wf || !tx) throw new MedusaError(MedusaError.Types.INVALID_DATA, 'wf and tx required')
const txn = await engine.getRunningTransaction(wf, tx) Defensive patterns
Strategy: validation
Validate before calling
if (!workflowId) throw new Error('workflowId is required')
await engine.getRunningTransaction(workflowId, transactionId) Type guard
const isNonEmptyString = (v: unknown): v is string => typeof v === 'string' && v.length > 0
Try / catch
catch (e) { if (e.message === 'Workflow ID is required') return badRequest(); throw e } Prevention
- Validate route params before forwarding to the engine
When it happens
Trigger: Calling getRunningTransaction('', txId) — typically from transaction()/engine wrappers that forward user-supplied or payload-derived ids unchecked.
Common situations: Dashboard/inspection endpoints receiving incomplete query params; integrations reading workflowId from event payloads that omit it.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- --paths must be a directory - ${additionalPath}
- --base must be a file - ${baseFile}
- not_found
- --config file must be of type .json or .yaml - ${configFileC
- invalid_data
AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27).
Data as JSON: /api/errors/2aa9d4cdbe861645.
Report an issue: GitHub.