Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: handle null plugin badges (#36767)

Crazywoola91c1d3ad8166
diff --git a/web/app/components/plugins/card/__tests__/index.spec.tsx b/web/app/components/plugins/card/__tests__/index.spec.tsx
index 37cdd58985d..b6c97dfd026 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(<Card payload={plugin} />)
+
+ 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 3208d97969f..d0202f2b351 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 0f03e17a05b..6053464a7a4 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'
}