Skip to content

fix(admin): handle null sales channel references in product list and detail views#15009

Open
Vitalini wants to merge 2 commits intomedusajs:developfrom
Vitalini:fix/admin-ui-orphaned-sales-channel-crash
Open

fix(admin): handle null sales channel references in product list and detail views#15009
Vitalini wants to merge 2 commits intomedusajs:developfrom
Vitalini:fix/admin-ui-orphaned-sales-channel-crash

Conversation

@Vitalini
Copy link
Copy Markdown

@Vitalini Vitalini commented Apr 4, 2026

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 null entries in the product's sales_channels array:

{
  "sales_channels": [null]
}

The Admin UI attempts to access sales_channel.name without null checks, causing:

TypeError: Cannot read properties of null (reading 'name')

This crashes both the product list page and the product detail page.

How

Added defensive null filtering in two components:

  1. SalesChannelsCell (product list table): Filters out null/undefined entries from the salesChannels array before rendering. Uses a TypeScript type guard to maintain type safety.

  2. ProductSalesChannelSection (product detail page): Filters out null/undefined entries 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

  • Product with all valid sales channels → renders normally (no change)
  • Product with sales_channels: [null] → shows placeholder instead of crashing
  • Product with mix of valid and null channels → shows only valid channels
  • Product with sales_channels: [] or null → 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 null entries for deleted sales-channel associations.

Overview
Prevents Admin UI crashes caused by orphaned product sales_channels entries by filtering out null/undefined items before rendering in both the product list (SalesChannelsCell) and product detail (ProductSalesChannelSection).

Adds a patch changeset for @medusajs/dashboard to release the fix.

Reviewed by Cursor Bugbot for commit 83e7d02. Bugbot is set up for automated code reviews on this repo. Configure here.

…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
@Vitalini Vitalini requested a review from a team as a code owner April 4, 2026 18:32
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 4, 2026

🦋 Changeset detected

Latest commit: 83e7d02

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

This PR includes changesets to release 77 packages
Name Type
@medusajs/dashboard Patch
@medusajs/admin-bundler Patch
@medusajs/medusa Patch
@medusajs/test-utils 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/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/core-flows Patch
@medusajs/framework Patch
@medusajs/js-sdk Patch
@medusajs/modules-sdk Patch
@medusajs/orchestration Patch
@medusajs/types Patch
@medusajs/utils Patch
@medusajs/workflows-sdk Patch
@medusajs/http-types-generator Patch
@medusajs/cli Patch
@medusajs/deps Patch
@medusajs/telemetry Patch
@medusajs/admin-sdk Patch
@medusajs/admin-shared Patch
@medusajs/admin-vite-plugin 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

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 4, 2026

@Vitalini is attempting to deploy a commit to the medusajs Team on Vercel.

A member of the Team first needs to authorize it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Admin UI: Product list crashes with TypeError when product has orphaned sales channel reference

1 participant