Skip to content

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

fix(web): hide product feedback in HIPAA deployments (#16526)

Lysander Kiesel7cd0bc086264
diff --git a/fern/apis/server/definition/feedback.yml b/fern/apis/server/definition/feedback.yml
index f151528a2d..2ec77719b6 100644
--- a/fern/apis/server/definition/feedback.yml
+++ b/fern/apis/server/definition/feedback.yml
@@ -4,7 +4,10 @@ service:
base-path: /api/public
endpoints:
submit:
- docs: Submit explicit user-approved feedback about Langfuse skills, MCP tools, CLI, docs, or public API. Do not include secrets, credentials, customer data, trace payloads, or unrelated use-case details.
+ docs: |
+ Submit explicit user-approved feedback about Langfuse skills, MCP tools, CLI, docs, or public API. Do not include secrets, credentials, customer data, trace payloads, or unrelated use-case details.
+
+ Not available in the HIPAA cloud region.
method: POST
path: /feedback
request: SubmitFeedbackRequest
diff --git a/web/public/generated/api/openapi.yml b/web/public/generated/api/openapi.yml
index 48a722972f..e6435ad853 100644
--- a/web/public/generated/api/openapi.yml
+++ b/web/public/generated/api/openapi.yml
@@ -1855,6 +1855,9 @@ paths:
Submit explicit user-approved feedback about Langfuse skills, MCP tools,
CLI, docs, or public API. Do not include secrets, credentials, customer
data, trace payloads, or unrelated use-case details.
+
+
+ Not available in the HIPAA cloud region.
operationId: feedback_submit
tags:
- Feedback
diff --git a/web/src/__tests__/server/unit/feedback-api.servertest.ts b/web/src/__tests__/server/unit/feedback-api.servertest.ts
index 4ba6f31e77..dc2fcdc891 100644
--- a/web/src/__tests__/server/unit/feedback-api.servertest.ts
+++ b/web/src/__tests__/server/unit/feedback-api.servertest.ts
@@ -1,5 +1,6 @@
import {
LangfuseConflictError,
+ LangfuseNotFoundError,
ServiceUnavailableError,
} from "@langfuse/shared";
import type { NextApiRequest, NextApiResponse } from "next";
@@ -149,4 +150,17 @@ describe("POST /api/public/feedback", () => {
error: "LangfuseConflictError",
});
});
+
+ it("returns 404 when product feedback is hidden", async () => {
+ mockSubmitFeedback.mockRejectedValueOnce(new LangfuseNotFoundError());
+ const { req, res } = createRequest(validBody);
+
+ await handler(req, res);
+
+ expect(res._getStatusCode()).toBe(404);
+ expect(JSON.parse(res._getData())).toMatchObject({
+ message: "Not Found",
+ error: "LangfuseNotFoundError",
+ });
+ });
});
diff --git a/web/src/__tests__/server/unit/feedback-service.servertest.ts b/web/src/__tests__/server/unit/feedback-service.servertest.ts
index 2a0c182668..8db09346e6 100644
--- a/web/src/__tests__/server/unit/feedback-service.servertest.ts
+++ b/web/src/__tests__/server/unit/feedback-service.servertest.ts
@@ -1,6 +1,7 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import {
LangfuseConflictError,
+ LangfuseNotFoundError,
ServiceUnavailableError,
} from "@langfuse/shared";
import type { ApiAccessScope } from "@langfuse/shared/src/server";
@@ -35,7 +36,12 @@ vi.mock("@/src/features/public-api/server/RateLimitService", () => ({
},
}));
-import { submitFeedback } from "@/src/features/feedback/server/FeedbackService";
+import {
+ isProductFeedbackAvailable,
+ submitFeedback,
+} from "@/src/features/feedback/server/FeedbackService";
+import { feedbackFeature } from "@/src/features/mcp/features/feedback";
+import { getMcpServerInstructions } from "@/src/features/mcp/server/mcpServer";
import { PostFeedbackBody } from "@/src/features/public-api/types/feedback";
const scope = {
@@ -254,7 +260,7 @@ describe("FeedbackService", () => {
);
});
- it("never delivers to Slack in the HIPAA region even with a configured sink", async () => {
+ it("hides product feedback in HIPAA without treating it as a missing sink", async () => {
(env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = "HIPAA";
const fetchMock = vi.fn();
vi.stubGlobal("fetch", fetchMock);
@@ -269,13 +275,20 @@ describe("FeedbackService", () => {
},
source: "public-api",
}),
- ).rejects.toBeInstanceOf(LangfuseConflictError);
+ ).rejects.toBeInstanceOf(LangfuseNotFoundError);
expect(fetchMock).not.toHaveBeenCalled();
- expect(mockRecordIncrement).toHaveBeenCalledWith(
- "langfuse.feedback.submission",
- 1,
- { source: "public-api", outcome: "sink_unconfigured" },
- );
+ expect(mockRateLimitRequest).not.toHaveBeenCalled();
+ expect(mockRecordIncrement).not.toHaveBeenCalled();
+ expect(mockLoggerWarn).not.toHaveBeenCalled();
+ expect(isProductFeedbackAvailable()).toBe(false);
+ expect(await feedbackFeature.isEnabled?.()).toBe(false);
+ expect(getMcpServerInstructions()).not.toContain("submitFeedback");
+ });
+
+ it("keeps the MCP feedback tool and instructions outside HIPAA", async () => {
+ expect(isProductFeedbackAvailable()).toBe(true);
+ expect(await feedbackFeature.isEnabled?.()).toBe(true);
+ expect(getMcpServerInstructions()).toContain("submitFeedback");
});
});
diff --git a/web/src/features/feedback/server/FeedbackService.ts b/web/src/features/feedback/server/FeedbackService.ts
index 1c39a8552a..c9d3493ec5 100644
--- a/web/src/features/feedback/server/FeedbackService.ts
+++ b/web/src/features/feedback/server/FeedbackService.ts
@@ -2,6 +2,7 @@ import { randomUUID } from "node:crypto";
import {
BaseError,
LangfuseConflictError,
+ LangfuseNotFoundError,
ServiceUnavailableError,
} from "@langfuse/shared";
import {
@@ -101,6 +102,14 @@ const appendPlainTextSection = (
const getDataRegion = (): string =>
env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION ?? "self-hosted";
+export const isHipaaCloudRegion = (): boolean =>
+ env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION === "HIPAA";
+
+// Product feedback is intentionally unavailable in HIPAA: Slack delivery is
+// not allowed, so the MCP tool and public endpoint should stay hidden rather
+// than fail as a misconfigured sink.
+export const isProductFeedbackAvailable = (): boolean => !isHipaaCloudRegion();
+
const feedbackSourceLabel: Record<FeedbackSource, string> = {
"langfuse-mcp": "Langfuse MCP",
"public-api": "Public API",
@@ -171,9 +180,7 @@ const buildFeedbackSlackMessage = ({
// The HIPAA region must never deliver feedback to Slack, even if a webhook
// were configured there by mistake.
const getConfiguredFeedbackWebhookUrl = (): string | undefined =>
- env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION === "HIPAA"
- ? undefined
- : env.LANGFUSE_FEEDBACK_INTAKE_SLACK_WEBHOOK;
+ isHipaaCloudRegion() ? undefined : env.LANGFUSE_FEEDBACK_INTAKE_SLACK_WEBHOOK;
const validateFeedbackWebhookUrl = (webhookUrl: string): string => {
let parsed: URL;
@@ -203,6 +210,10 @@ export const submitFeedback = async ({
source: FeedbackSource;
scope: ApiAccessScope;
}): Promise<PostFeedbackResponseType> => {
+ if (!isProductFeedbackAvailable()) {
+ throw new LangfuseNotFoundError();
+ }
+
const rateLimitCheck = await RateLimitService.getInstance().rateLimitRequest(
scope,
"feedback",
diff --git a/web/src/features/mcp/features/feedback/index.ts b/web/src/features/mcp/features/feedback/index.ts
index 1f4bfc092c..98fa784508 100644
--- a/web/src/features/mcp/features/feedback/index.ts
+++ b/web/src/features/mcp/features/feedback/index.ts
@@ -1,3 +1,4 @@
+import { isProductFeedbackAvailable } from "@/src/features/feedback/server/FeedbackService";
import type { McpFeatureModule } from "../../server/registry";
import {
handleSubmitFeedback,
@@ -14,4 +15,5 @@ export const feedbackFeature = {
handler: handleSubmitFeedback,
},
],
+ isEnabled: async () => isProductFeedbackAvailable(),
} as const satisfies McpFeatureModule;
diff --git a/web/src/features/mcp/server/mcpServer.ts b/web/src/features/mcp/server/mcpServer.ts
index 70eb09735b..9871da142d 100644
--- a/web/src/features/mcp/server/mcpServer.ts
+++ b/web/src/features/mcp/server/mcpServer.ts
@@ -17,6 +17,7 @@ import {
ListToolsRequestSchema,
CallToolRequestSchema,
} from "@modelcontextprotocol/sdk/types.js";
+import { isProductFeedbackAvailable } from "@/src/features/feedback/server/FeedbackService";
import type { ServerContext } from "../types";
import { toolRegistry } from "./registry";
import { contextWithLangfuseProps, logger } from "@langfuse/shared/src/server";
@@ -32,8 +33,14 @@ const MCP_SERVER_INSTRUCTIONS = [
"Use this server for project-scoped Langfuse data and actions such as prompts, datasets, scores, comments, metrics, observations etc.",
"Inspect the available tools and their schemas dynamically; do not assume a fixed tool list.",
"For conceptual Langfuse product guidance, SDK/API documentation, instrumentation help, or prompt-migration guidance, prefer the Langfuse docs MCP server or installed Langfuse agent skills when they are available.",
- "To send feedback about Langfuse skills, MCP tools, CLI, docs, or public API, ask the user for permission and show the exact feedback payload; if they want a reply, include only an email address they explicitly provide in the feedback text; exclude secrets, customer/project data, trace payloads, and unrelated context, then call submitFeedback.",
-].join("\n");
+];
+const MCP_FEEDBACK_INSTRUCTION =
+ "To send feedback about Langfuse skills, MCP tools, CLI, docs, or public API, ask the user for permission and show the exact feedback payload; if they want a reply, include only an email address they explicitly provide in the feedback text; exclude secrets, customer/project data, trace payloads, and unrelated context, then call submitFeedback.";
+
+export const getMcpServerInstructions = (): string =>
+ isProductFeedbackAvailable()
+ ? [...MCP_SERVER_INSTRUCTIONS, MCP_FEEDBACK_INSTRUCTION].join("\n")
+ : MCP_SERVER_INSTRUCTIONS.join("\n");
/**
* Create and configure the MCP server instance.
@@ -64,7 +71,7 @@ export function createMcpServer(context: ServerContext): Server {
capabilities: {
tools: {},
},
- instructions: MCP_SERVER_INSTRUCTIONS,
+ instructions: getMcpServerInstructions(),
},
);