medusajs/medusa · error · MedusaError
Line item ${item.title} has no unit price
Error message
Line item ${item.title} has no unit price What it means
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.
Source
Thrown at packages/core/core-flows/src/cart/workflows/update-line-item-in-cart.ts:137
// produced the line item.
if (!isDefined(input.update.compare_at_unit_price)) {
const isSalePrice =
variant.calculated_price?.calculated_price?.price_list_type ===
PriceListType.SALE
updateData.compare_at_unit_price =
isSalePrice &&
!MathBN.eq(
variant.calculated_price?.original_amount,
variant.calculated_price?.calculated_amount
)
? variant.calculated_price.original_amount
: null
}
}
if (!isDefined(updateData.unit_price)) {
throw new MedusaError(
MedusaError.Types.INVALID_DATA,
`Line item ${item.title} has no unit price`
)
}
return new StepResponse({
data: updateData,
selector: {
id: input.item_id,
},
})
}
)
export const updateLineItemInCartWorkflowId = "update-line-item-in-cart"
/**
* This workflow updates a line item's details in a cart. You can update the line item's quantity, unit price, and more.
* If the quantity is set to 0, the item will be removed from the cart.View on GitHub (pinned to 5e06e544a2)
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)
Example fix
// before
await updateLineItemInCartWorkflow(container).run({
input: { cart_id, item_id, update: { quantity: 2 } },
})
// throws: Line item ... has no unit price
// after (admin: supply price explicitly)
await updateLineItemInCartWorkflow(container).run({
input: { cart_id, item_id, update: { quantity: 2, unit_price: 1500 } },
}) Defensive patterns
Strategy: validation
Validate before calling
const variant = await query.graph({
entity: "product_variant",
filters: { id: variantId },
fields: ["id", "calculated_price.calculated_amount"],
context: { region_id: cart.region_id },
})
const hasPrice =
variant.data[0]?.calculated_price?.calculated_amount != null ||
update.unit_price != null Try / catch
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 } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- invalid_data
- invalid_data
- Variants with IDs ${priceNotFound.join(", ")} do not have a
- Line item with id: ${input.item_id} was not found
- Skipping refund of payment ${paymentSession.payment.id}: a l
AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27).
Data as JSON: /api/errors/91ca42d8571c747e.
Report an issue: GitHub.