Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(frontend/admin): guard against undefined platform in PlatformBadge (#13581)

seer-by-sentry[bot]3ddb119a8d5f
diff --git a/autogpt_platform/frontend/src/app/(platform)/admin/bots/__tests__/main.test.tsx b/autogpt_platform/frontend/src/app/(platform)/admin/bots/__tests__/main.test.tsx
index c6f4462238..28d6c5bace 100644
--- a/autogpt_platform/frontend/src/app/(platform)/admin/bots/__tests__/main.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/admin/bots/__tests__/main.test.tsx
@@ -1,3 +1,4 @@
+import { http, HttpResponse } from "msw";
import { describe, expect, it } from "vitest";
import {
@@ -70,6 +71,25 @@ function mockAllEndpoints() {
}
describe("BotsContent", () => {
+ it("keeps rows visible when a response omits platform", async () => {
+ mockAllEndpoints();
+ server.use(
+ http.get("*/api/proxy/api/admin/bot-analytics/top-servers", () =>
+ HttpResponse.json([
+ {
+ server_id: "legacy-1",
+ name: "Legacy server",
+ messages: 7,
+ commands: 2,
+ },
+ ]),
+ ),
+ );
+ render(<BotsContent />);
+ expect(await screen.findByText("Legacy server")).toBeDefined();
+ expect(await screen.findByText("/setup")).toBeDefined();
+ });
+
it("renders the live server count and headline metrics", async () => {
mockAllEndpoints();
render(<BotsContent />);
diff --git a/autogpt_platform/frontend/src/app/(platform)/admin/bots/components/PlatformBadge.tsx b/autogpt_platform/frontend/src/app/(platform)/admin/bots/components/PlatformBadge.tsx
index d4e18cdb30..a972610f6a 100644
--- a/autogpt_platform/frontend/src/app/(platform)/admin/bots/components/PlatformBadge.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/admin/bots/components/PlatformBadge.tsx
@@ -10,10 +10,11 @@ const PLATFORM_LABELS: Record<string, string> = Object.fromEntries(
);
interface Props {
- platform: string;
+ platform: string | undefined;
}
export function PlatformBadge({ platform }: Props) {
+ if (!platform) return null;
const key = platform.toUpperCase();
const label = PLATFORM_LABELS[key] ?? platform;