From 91c1d3ad816685d1dae394080443c6dc5ae90742 Mon Sep 17 00:00:00 2001 From: Crazywoola <100913391+crazywoola@users.noreply.github.com> Date: Thu, 28 May 2026 15:00:32 +0800 Subject: [PATCH] fix: handle null plugin badges (#36767) --- web/app/components/plugins/card/__tests__/index.spec.tsx | 8 ++++++++ web/app/components/plugins/card/index.tsx | 3 ++- web/app/components/plugins/types.ts | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/web/app/components/plugins/card/__tests__/index.spec.tsx b/web/app/components/plugins/card/__tests__/index.spec.tsx index 37cdd58985..b6c97dfd02 100644 --- a/web/app/components/plugins/card/__tests__/index.spec.tsx +++ b/web/app/components/plugins/card/__tests__/index.spec.tsx @@ -465,6 +465,14 @@ describe('Card', () => { expect(screen.queryByTestId('partner-badge')).not.toBeInTheDocument() }) + + it('should handle null badges from the marketplace API', () => { + const plugin = createMockPlugin({ badges: null }) + + render() + + expect(screen.queryByTestId('partner-badge')).not.toBeInTheDocument() + }) }) // ================================ diff --git a/web/app/components/plugins/card/index.tsx b/web/app/components/plugins/card/index.tsx index 3208d97969..d0202f2b35 100644 --- a/web/app/components/plugins/card/index.tsx +++ b/web/app/components/plugins/card/index.tsx @@ -53,7 +53,8 @@ const Card = ({ const { t } = useTranslation() const { categoriesMap } = useCategories(true) const currentWorkspaceId = useSelector(s => s.currentWorkspace.id) - const { category, type, name, org, label, brief, icon, icon_dark, verified, badges = [], from } = payload + const { category, type, name, org, label, brief, icon, icon_dark, verified, from } = payload + const badges = payload.badges ?? [] const { theme } = useTheme() const iconSrc = getPluginCardIconUrl( { from, name, org, type }, diff --git a/web/app/components/plugins/types.ts b/web/app/components/plugins/types.ts index 0f03e17a05..6053464a7a 100644 --- a/web/app/components/plugins/types.ts +++ b/web/app/components/plugins/types.ts @@ -190,7 +190,7 @@ export type PluginManifestInMarket = { introduction: string verified: boolean install_count: number - badges: string[] + badges: string[] | null verification: { authorized_category: 'langgenius' | 'partner' | 'community' } @@ -255,7 +255,7 @@ export type Plugin = { settings: CredentialFormSchemaBase[] } tags: { name: string }[] - badges: string[] + badges: string[] | null verification: { authorized_category: 'langgenius' | 'partner' | 'community' }