Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(shared,web): make project-notification dispatch exhaustive (#16281)

Niklas Semmler7b1eeb952e9c
diff --git a/packages/shared/src/server/notifications/dispatchProjectNotification.ts b/packages/shared/src/server/notifications/dispatchProjectNotification.ts
index 60297130a3..841867341a 100644
--- a/packages/shared/src/server/notifications/dispatchProjectNotification.ts
+++ b/packages/shared/src/server/notifications/dispatchProjectNotification.ts
@@ -210,5 +210,11 @@ async function sendEventAdminEmails({
);
return;
}
+ default: {
+ const _exhaustiveCheck: never = event;
+ throw new Error(
+ `sendEventAdminEmails: unhandled event type ${(_exhaustiveCheck as ProjectNotificationEvent).eventType}`,
+ );
+ }
}
}
diff --git a/web/src/features/notifications/components/ProjectNotificationChannels.clienttest.tsx b/web/src/features/notifications/components/ProjectNotificationChannels.clienttest.tsx
new file mode 100644
index 0000000000..48a9a73641
--- /dev/null
+++ b/web/src/features/notifications/components/ProjectNotificationChannels.clienttest.tsx
@@ -0,0 +1,18 @@
+import { ProjectNotificationEventTypeSchema } from "@langfuse/shared";
+
+import { NOTIFIED_EVENTS } from "@/src/features/notifications/components/ProjectNotificationChannels";
+
+describe("NOTIFIED_EVENTS", () => {
+ it("has exactly one entry per ProjectNotificationEventTypeSchema member", () => {
+ expect(NOTIFIED_EVENTS.map((event) => event.value).sort()).toEqual(
+ [...ProjectNotificationEventTypeSchema.options].sort(),
+ );
+ });
+
+ it("gives every entry a non-empty title and description", () => {
+ for (const event of NOTIFIED_EVENTS) {
+ expect(event.title).not.toBe("");
+ expect(event.description).not.toBe("");
+ }
+ });
+});
diff --git a/web/src/features/notifications/components/ProjectNotificationChannels.tsx b/web/src/features/notifications/components/ProjectNotificationChannels.tsx
index ae40f282a2..d4cad4730f 100644
--- a/web/src/features/notifications/components/ProjectNotificationChannels.tsx
+++ b/web/src/features/notifications/components/ProjectNotificationChannels.tsx
@@ -16,6 +16,7 @@ import { ProjectNotificationChannelsList } from "@/src/features/notifications/co
import { useProjectNotificationChannels } from "@/src/features/notifications/hooks/useProjectNotificationChannels";
import { cn } from "@/src/utils/tailwind";
import {
+ ProjectNotificationEventTypeSchema,
TriggerEventSource,
type ActionTypes,
type ProjectNotificationEventType,
@@ -24,30 +25,30 @@ import {
/** Project notifications route to webhooks or Slack; GitHub dispatch is not wired for this event source. */
const PROJECT_NOTIFICATION_ACTION_TYPES: ActionTypes[] = ["WEBHOOK", "SLACK"];
-/** NOTIFIED_EVENTS lists the toggleable project-notification events, keyed by their eventType. */
-const NOTIFIED_EVENTS: {
- value: ProjectNotificationEventType;
- title: string;
- description: string;
-}[] = [
- {
- value: "blob-export-failed",
+const NOTIFIED_EVENT_COPY: Record<
+ ProjectNotificationEventType,
+ { title: string; description: string }
+> = {
+ "blob-export-failed": {
title: "Blob storage export failed",
description: "Sent when a scheduled blob storage export fails.",
},
- {
- value: "posthog-export-failed",
+ "posthog-export-failed": {
title: "PostHog export failed",
description:
"Sent when a PostHog export is disabled after a configuration error, such as an unreachable host.",
},
- {
- value: "evaluator-blocked",
+ "evaluator-blocked": {
title: "Evaluator deactivated",
description:
"Sent when an evaluator is deactivated due to an unrecoverable error, such as a deleted model or LLM connection.",
},
-];
+};
+
+/** NOTIFIED_EVENTS lists the toggleable project-notification events, in schema order. */
+export const NOTIFIED_EVENTS = ProjectNotificationEventTypeSchema.options.map(
+ (value) => ({ value, ...NOTIFIED_EVENT_COPY[value] }),
+);
/**
* ProjectNotificationChannels is the admin-only "Project Notifications"