fix(admin): handle null sales channel references in product list and detail views#15009
Open
Vitalini wants to merge 2 commits intomedusajs:developfrom
Open
fix(admin): handle null sales channel references in product list and detail views#15009Vitalini wants to merge 2 commits intomedusajs:developfrom
Vitalini wants to merge 2 commits intomedusajs:developfrom
Conversation
…detail views When a sales channel is deleted but the product-to-sales-channel association is not cleaned up, the API returns null entries in the product's sales_channels array. This causes the Admin UI to crash with 'TypeError: Cannot read properties of null (reading "name")'. This commit adds defensive null filtering in: - SalesChannelsCell: filters out null entries before rendering the product list table cell - ProductSalesChannelSection: filters out null entries before rendering the product detail sales channels section Fixes medusajs#14945
🦋 Changeset detectedLatest commit: 83e7d02 The changes in this PR will be included in the next version bump. This PR includes changesets to release 77 packages
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 |
|
@Vitalini is attempting to deploy a commit to the medusajs Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes a crash in the Admin UI when a product has orphaned sales channel references (i.e., the sales channel was deleted but the product association was not cleaned up).
Why
When a sales channel is deleted, the join table entries linking it to products are not always cleaned up. This results in the API returning
nullentries in the product'ssales_channelsarray:{ "sales_channels": [null] }The Admin UI attempts to access
sales_channel.namewithout null checks, causing:This crashes both the product list page and the product detail page.
How
Added defensive null filtering in two components:
SalesChannelsCell(product list table): Filters outnull/undefinedentries from thesalesChannelsarray before rendering. Uses a TypeScript type guard to maintain type safety.ProductSalesChannelSection(product detail page): Filters outnull/undefinedentries before mapping sales channels for display.Both components now gracefully handle orphaned references by simply excluding them from the rendered output, showing only valid sales channels.
Testing
sales_channels: [null]→ shows placeholder instead of crashingsales_channels: []ornull→ shows placeholder (existing behavior, unchanged)Fixes #14945
Note
Low Risk
Low risk UI-only change that adds defensive filtering to avoid crashes when the API returns
nullentries for deleted sales-channel associations.Overview
Prevents Admin UI crashes caused by orphaned product
sales_channelsentries by filtering outnull/undefineditems before rendering in both the product list (SalesChannelsCell) and product detail (ProductSalesChannelSection).Adds a patch changeset for
@medusajs/dashboardto release the fix.Reviewed by Cursor Bugbot for commit 83e7d02. Bugbot is set up for automated code reviews on this repo. Configure here.