{"record":{"id":"91ca42d8571c747e","repo":"medusajs/medusa","slug":"line-item-item-title-has-no-unit-price","errorCode":null,"errorMessage":"Line item ${item.title} has no unit price","messagePattern":"Line item (.+?) has no unit price","errorType":"exception","errorClass":"MedusaError","httpStatus":400,"severity":"error","filePath":"packages/core/core-flows/src/cart/workflows/update-line-item-in-cart.ts","lineNumber":137,"sourceCode":"      // produced the line item.\n      if (!isDefined(input.update.compare_at_unit_price)) {\n        const isSalePrice =\n          variant.calculated_price?.calculated_price?.price_list_type ===\n          PriceListType.SALE\n\n        updateData.compare_at_unit_price =\n          isSalePrice &&\n          !MathBN.eq(\n            variant.calculated_price?.original_amount,\n            variant.calculated_price?.calculated_amount\n          )\n            ? variant.calculated_price.original_amount\n            : null\n      }\n    }\n\n    if (!isDefined(updateData.unit_price)) {\n      throw new MedusaError(\n        MedusaError.Types.INVALID_DATA,\n        `Line item ${item.title} has no unit price`\n      )\n    }\n\n    return new StepResponse({\n      data: updateData,\n      selector: {\n        id: input.item_id,\n      },\n    })\n  }\n)\n\nexport const updateLineItemInCartWorkflowId = \"update-line-item-in-cart\"\n/**\n * This workflow updates a line item's details in a cart. You can update the line item's quantity, unit price, and more.\n * If the quantity is set to 0, the item will be removed from the cart.","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/core/core-flows/src/cart/workflows/update-line-item-in-cart.ts#L119-L155","documentation":"Thrown by updateLineItemInCartStep when the line item being updated has no unit_price and none can be derived. The step builds updateData from the variant's calculated price (original_amount); if the variant has no calculated price and the caller did not pass unit_price, the update cannot proceed.","triggerScenarios":"Calling updateLineItemInCartWorkflow (Store or Admin API) for an item whose variant has no pricing record for the cart's region/currency context (e.g. money amounts not seeded, wrong region), and no explicit unit_price supplied in the update input.","commonSituations":"Fresh install without price list/region seeding; variant added before money amounts were configured; region/currency mismatch between cart and price list; tests running without pricing fixtures.","solutions":["Verify the variant has a calculated price for the cart's region/currency (query product variants with calculated_price context)","Add money amounts / price list entries for the variant in the cart's region and currency","Pass an explicit unit_price in the workflow/admin input (admin-only override)"],"exampleFix":"// before\nawait updateLineItemInCartWorkflow(container).run({\n  input: { cart_id, item_id, update: { quantity: 2 } },\n})\n// throws: Line item ... has no unit price\n\n// after (admin: supply price explicitly)\nawait updateLineItemInCartWorkflow(container).run({\n  input: { cart_id, item_id, update: { quantity: 2, unit_price: 1500 } },\n})","handlingStrategy":"validation","validationCode":"const variant = await query.graph({\n  entity: \"product_variant\",\n  filters: { id: variantId },\n  fields: [\"id\", \"calculated_price.calculated_amount\"],\n  context: { region_id: cart.region_id },\n})\nconst hasPrice =\n  variant.data[0]?.calculated_price?.calculated_amount != null ||\n  update.unit_price != null","typeGuard":null,"tryCatchPattern":"try { await updateLineItemInCartWorkflow(scope).run({ input }) } catch (e) { if (e instanceof MedusaError && e.type === MedusaError.Types.INVALID_DATA && /no unit price/.test(e.message)) { /* re-seed pricing or pass unit_price */ } throw e }","preventionTips":["Seed money amounts for every region/currency you sell in","Include unit_price in admin-driven line item updates","Assert variant calculated prices in test fixtures"],"tags":["cart","pricing","line-item","core-flows"],"backgroundTag":"missing-price-for-region","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}