Skip to content

fix(pricing): don't drop price list updates that carry explicit ids - #17439

Merged
kodiakhq[bot] merged 1 commit into
developfrom
fix/pricing-keep-price-updates-with-explicit-ids
Oct 23, 2026
Merged

kodiakhq[bot] merged 1 commit into
developfrom
fix/pricing-keep-price-updates-with-explicit-ids

Conversation

@medusa-os-bot

@medusa-os-bot medusa-os-bot Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Summary

What — Price updates that carry distinct explicit ids are no longer collapsed into one when they omit the optional currency and quantity fields.

Why — Calling updatePriceListPrices (for example through batchPriceListPricesWorkflow or the admin price list batch route) with several { id, price_set_id, amount } updates for prices in the same price set only applied the last one. The others were silently dropped and the workflow still succeeded. normalizePrices deduplicated the input by a hash of the identity fields it contained, and that hash ignores id. Partial updates without currency or quantity fields all produced the same hash, so each one overwrote the previous entry in the map.

How — In packages/modules/pricing/src/services/pricing-module.ts (normalizePrices), entries are now keyed by their id when present: either the explicit id or the id copied from a matched existing price. Entries without an id still fall back to the hash, so prices that match an existing row are still deduplicated as before.

Testing — Added should update every price identified by id when quantity fields are omitted to packages/modules/pricing/integration-tests/__tests__/services/pricing-module/price-list.spec.ts. It creates two quantity-band prices (1-9 and 10+) in one price list and price set, then updates both by id with only price_set_id and amount. Before the fix it fails with ["price-band-1", 1, 80] (expected 78). After the fix it passes. The full pricing module integration suite (138 tests) and the unit suite pass.


Checklist

  • I have added a changeset for this PR
  • The changes are covered by relevant tests
  • I have verified the code works as intended locally
  • I have linked the related issue(s) if applicable

Additional Context

  • Module integration tests load the package's built dist. To verify, the same one-line change was applied to the local build output, because a rebuild couldn't be run in this environment.
  • Related, not changed here: when an update with an explicit id has full identity fields that match a different existing price that was also fetched, normalizePrices replaces the supplied id with the matched price's id (entry.id = existing.id ?? entry.id). updatePriceListPrices_ only fetches the existing rows by id when ids are supplied, so this case doesn't arise in the reported flow.

Fixes #17289

Opened automatically by the Fix Bug workflow. Review carefully before merging.

@medusa-os-bot
medusa-os-bot Bot requested a review from a team as a code owner October 22, 2026 16:17
@changeset-bot

changeset-bot Bot commented Oct 22, 2026

Copy link
Copy Markdown

ðŸĶ‹ Changeset detected

Latest commit: 322a71f

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

This PR includes changesets to release 83 packages
Name Type
@medusajs/pricing Patch
@medusajs/medusa Patch
@medusajs/test-utils Patch
@medusajs/loyalty-plugin Patch
@medusajs/medusa-oas-cli Patch
integration-tests-http 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/product Patch
@medusajs/promotion Patch
@medusajs/rbac Patch
@medusajs/region Patch
@medusajs/sales-channel Patch
@medusajs/search 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/search-postgres 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/auth-oidc 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/core-flows Patch
@medusajs/framework Patch
@medusajs/instantsearch-adapter 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
create-medusa-app 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
@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 Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the contribution! Initial automated review looks good.

Verdict: Looks good for a final review by the team.

Changes normalizePrices to key the deduplication map by entry.id when an id is present, so multiple prices sharing the same identity-field hash but carrying distinct ids are no longer collapsed into one entry and silently dropped.

Checked: security, performance, correctness, conventions, tests. The fix is a one-liner that preserves the existing hash-based deduplication for entries without ids. All five callers of normalizePrices are unaffected. The integration test covers the exact failing scenario (two quantity-banded prices updated by id without currency/quantity fields).

Triggered by: new PR opened

@kodiakhq
kodiakhq Bot merged commit f7d822b into develop Oct 23, 2026
38 checks passed
@kodiakhq
kodiakhq Bot deleted the fix/pricing-keep-price-updates-with-explicit-ids branch October 23, 2026 06:53
@github-actions github-actions Bot mentioned this pull request Oct 23, 2026
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.

[Bug]: Price-list updates carrying explicit price IDs are silently dropped when quantity fields are omitted

1 participant