Skip to content

Fix cart price null crash#15935

Open
Abhishekvenky010 wants to merge 3 commits into
medusajs:developfrom
Abhishekvenky010:fix-cart-price-null-crash
Open

Fix cart price null crash#15935
Abhishekvenky010 wants to merge 3 commits into
medusajs:developfrom
Abhishekvenky010:fix-cart-price-null-crash

Conversation

@Abhishekvenky010

Copy link
Copy Markdown

Fixes a runtime crash in POST /store/carts/{id}/line-items when a variant exists but has no calculated price for the cart’s region/currency. The code previously accessed calculatedPriceSet without checking for existence, causing a TypeError and resulting in a 500 error instead of a proper validation error.

This change adds a guard for calculatedPriceSet and ensures the flow returns the intended INVALID_DATA error for missing variant prices.

@Abhishekvenky010 Abhishekvenky010 requested a review from a team as a code owner July 3, 2026 18:08
@changeset-bot

changeset-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a39c8ec

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 80 packages
Name Type
@medusajs/core-flows Patch
@medusajs/medusa Patch
@medusajs/test-utils Patch
integration-tests-http Patch
@medusajs/loyalty-plugin Patch
@medusajs/medusa-oas-cli Patch
@medusajs/analytics Patch
@medusajs/api-key Patch
@medusajs/auth Patch
@medusajs/caching Patch
@medusajs/cart Patch
@medusajs/currency Patch
@medusajs/customer Patch
@medusajs/file Patch
@medusajs/fulfillment Patch
@medusajs/index Patch
@medusajs/inventory Patch
@medusajs/link-modules Patch
@medusajs/locking Patch
@medusajs/notification Patch
@medusajs/order Patch
@medusajs/payment Patch
@medusajs/pricing Patch
@medusajs/product Patch
@medusajs/promotion Patch
@medusajs/rbac Patch
@medusajs/region Patch
@medusajs/sales-channel Patch
@medusajs/settings Patch
@medusajs/stock-location Patch
@medusajs/store Patch
@medusajs/tax Patch
@medusajs/translation Patch
@medusajs/user Patch
@medusajs/workflow-engine-inmemory Patch
@medusajs/workflow-engine-redis Patch
@medusajs/draft-order Patch
@medusajs/oas-github-ci Patch
@medusajs/cache-inmemory Patch
@medusajs/cache-redis Patch
@medusajs/event-bus-local Patch
@medusajs/event-bus-redis Patch
@medusajs/analytics-local Patch
@medusajs/analytics-posthog Patch
@medusajs/auth-emailpass Patch
@medusajs/auth-github Patch
@medusajs/auth-google Patch
@medusajs/caching-redis Patch
@medusajs/file-local Patch
@medusajs/file-s3 Patch
@medusajs/fulfillment-manual Patch
@medusajs/locking-postgres Patch
@medusajs/locking-redis Patch
@medusajs/notification-local Patch
@medusajs/notification-sendgrid Patch
@medusajs/payment-stripe Patch
@medusajs/framework Patch
@medusajs/js-sdk Patch
@medusajs/modules-sdk Patch
@medusajs/orchestration Patch
@medusajs/query Patch
@medusajs/types Patch
@medusajs/utils Patch
@medusajs/workflows-sdk Patch
@medusajs/http-types-generator Patch
@medusajs/cli Patch
@medusajs/deps Patch
@medusajs/eslint-plugin Patch
@medusajs/telemetry Patch
@medusajs/admin-bundler Patch
@medusajs/admin-sdk Patch
@medusajs/admin-shared Patch
@medusajs/admin-vite-plugin Patch
@medusajs/dashboard Patch
@medusajs/icons Patch
@medusajs/toolbox Patch
@medusajs/ui-preset Patch
create-medusa-app Patch
medusa-dev-cli Patch
@medusajs/ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@medusa-os-bot

medusa-os-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

Thanks for the contribution! A few items need to be addressed before this can move forward:

The one-line code fix is sound and minimal: guarding calculatedPriceSet before reading calculated_amount prevents the TypeError, and the pre-existing priceNotFound check still surfaces the intended INVALID_DATA error. Two things need fixing before approval: the changeset content is incorrect, and the PR template's Testing section is not filled in. A regression test would also strengthen this core-flow change.

  • .changeset/fix-calculatedPriceSet-guard.md is wrong: it targets @medusajs/query with unrelated text ('Refactor query logic...'). It should target @medusajs/core-flows (patch) and describe this cart pr
  • Fill in the PR template's Testing section describing how the no-regional-price case was verified (adding a line item now returns INVALID_DATA instead of a 500).
  • Consider adding a regression test covering the variant-without-price path in get-variants-and-items-with-prices.

Triggered by: new PR opened

@medusa-os-bot

medusa-os-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

Thanks for the contribution! We need more information before reviewing this further.

Good progress since the prior review: the changeset now correctly targets @medusajs/core-flows and a regression test was added for the variant-without-price path. The one-line guard is sound and lets the flow surface the intended INVALID_DATA error instead of a 500. One item from the prior review is still open: the PR description does not follow the template and the Testing section is not filled in.

Triggered by: new commit pushed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant