Skip to content

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

fix: add error message for missing encryption key for self-hosters (#7090)

Max Deichmann0f056c1c2dbd
diff --git a/web/src/features/llm-api-key/server/router.ts b/web/src/features/llm-api-key/server/router.ts
index e9414d17bd..a055c1e28c 100644
--- a/web/src/features/llm-api-key/server/router.ts
+++ b/web/src/features/llm-api-key/server/router.ts
@@ -21,6 +21,8 @@ import {
LLMAdapter,
logger,
} from "@langfuse/shared/src/server";
+import { env } from "@/src/env.mjs";
+import { TRPCError } from "@trpc/server";
export function getDisplaySecretKey(secretKey: string) {
return secretKey.endsWith('"}')
@@ -39,6 +41,21 @@ export const llmApiKeyRouter = createTRPCRouter({
scope: "llmApiKeys:create",
});
+ if (!env.ENCRYPTION_KEY) {
+ if (env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION) {
+ throw new TRPCError({
+ code: "INTERNAL_SERVER_ERROR",
+ message: "Internal server error",
+ });
+ } else {
+ throw new TRPCError({
+ code: "BAD_REQUEST",
+ message:
+ "Missing environment variable: `ENCRYPTION_KEY`. Please consult our docs: https://langfuse.com/self-hosting",
+ });
+ }
+ }
+
const key = await ctx.prisma.llmApiKeys.create({
data: {
projectId: input.projectId,