{"record":{"id":"2aa9d4cdbe861645","repo":"medusajs/medusa","slug":"insufficient-inventory","errorCode":"insufficient_inventory","errorMessage":"Some variant does not have the required inventory","messagePattern":"Some variant does not have the required inventory","errorType":"validation","errorClass":"MedusaError","httpStatus":400,"severity":"error","filePath":"packages/core/core-flows/src/cart/steps/confirm-inventory.ts","lineNumber":92,"sourceCode":"    // TODO: Should be bulk\n    const promises = data.items.map(async (item) => {\n      if (item.allow_backorder) {\n        return true\n      }\n\n      const itemQuantity = MathBN.mult(item.quantity, item.required_quantity)\n\n      return await inventoryService.confirmInventory(\n        item.inventory_item_id,\n        item.location_ids,\n        itemQuantity\n      )\n    })\n\n    const inventoryCoverage = await promiseAll(promises)\n\n    if (inventoryCoverage.some((hasCoverage) => !hasCoverage)) {\n      throw new MedusaError(\n        MedusaError.Types.NOT_ALLOWED,\n        `Some variant does not have the required inventory`,\n        MedusaError.Codes.INSUFFICIENT_INVENTORY\n      )\n    }\n\n    return new StepResponse(null)\n  }\n)\n","sourceCodeStart":74,"sourceCodeEnd":102,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/core/core-flows/src/cart/steps/confirm-inventory.ts#L74-L102","documentation":"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.","triggerScenarios":"Calling getRunningTransaction('', txId) — typically from transaction()/engine wrappers that forward user-supplied or payload-derived ids unchecked.","commonSituations":"Dashboard/inspection endpoints receiving incomplete query params; integrations reading workflowId from event payloads that omit it.","solutions":["Validate workflowId presence before calling","Default to the known workflow id from your own constants","Return 400 from HTTP layers early"],"exampleFix":"// before\nconst tx = await engine.getRunningTransaction(req.query.wf, req.query.tx)\n// after\nconst { wf, tx } = req.query\nif (!wf || !tx) throw new MedusaError(MedusaError.Types.INVALID_DATA, 'wf and tx required')\nconst txn = await engine.getRunningTransaction(wf, tx)","handlingStrategy":"validation","validationCode":"if (!workflowId) throw new Error('workflowId is required')\nawait engine.getRunningTransaction(workflowId, transactionId)","typeGuard":"const isNonEmptyString = (v: unknown): v is string => typeof v === 'string' && v.length > 0","tryCatchPattern":"catch (e) { if (e.message === 'Workflow ID is required') return badRequest(); throw e }","preventionTips":["Validate route params before forwarding to the engine"],"tags":["workflow-engine","redis","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}