Skip to content

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

fix(init): warn when LANGFUSE_INIT_* env vars are partially configured (#11122)

Steffen Schmitz53229a97677c
diff --git a/web/src/initialize.ts b/web/src/initialize.ts
index a5c24e89e4..496f24ee96 100644
--- a/web/src/initialize.ts
+++ b/web/src/initialize.ts
@@ -5,6 +5,31 @@ import { createAndAddApiKeysToDb } from "@langfuse/shared/src/server/auth/apiKey
import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";
import { getOrganizationPlanServerSide } from "@/src/features/entitlements/server/getPlan";
import { CloudConfigSchema } from "@langfuse/shared";
+import { logger } from "@langfuse/shared/src/server";
+
+// Warn if LANGFUSE_INIT_* variables are set but LANGFUSE_INIT_ORG_ID is missing
+if (!env.LANGFUSE_INIT_ORG_ID) {
+ const setInitVars = [
+ env.LANGFUSE_INIT_ORG_NAME && "LANGFUSE_INIT_ORG_NAME",
+ env.LANGFUSE_INIT_ORG_CLOUD_PLAN && "LANGFUSE_INIT_ORG_CLOUD_PLAN",
+ env.LANGFUSE_INIT_PROJECT_ID && "LANGFUSE_INIT_PROJECT_ID",
+ env.LANGFUSE_INIT_PROJECT_NAME && "LANGFUSE_INIT_PROJECT_NAME",
+ env.LANGFUSE_INIT_PROJECT_RETENTION && "LANGFUSE_INIT_PROJECT_RETENTION",
+ env.LANGFUSE_INIT_PROJECT_PUBLIC_KEY && "LANGFUSE_INIT_PROJECT_PUBLIC_KEY",
+ env.LANGFUSE_INIT_PROJECT_SECRET_KEY && "LANGFUSE_INIT_PROJECT_SECRET_KEY",
+ env.LANGFUSE_INIT_USER_EMAIL && "LANGFUSE_INIT_USER_EMAIL",
+ env.LANGFUSE_INIT_USER_NAME && "LANGFUSE_INIT_USER_NAME",
+ env.LANGFUSE_INIT_USER_PASSWORD && "LANGFUSE_INIT_USER_PASSWORD",
+ ].filter(Boolean) as string[];
+
+ if (setInitVars.length > 0) {
+ logger.warn(
+ `[Langfuse Init] LANGFUSE_INIT_ORG_ID is not set but other LANGFUSE_INIT_* variables are configured. ` +
+ `The following variables will be ignored: ${setInitVars.join(", ")}. ` +
+ `Set LANGFUSE_INIT_ORG_ID to enable initialization.`,
+ );
+ }
+}
// Create Organization
if (env.LANGFUSE_INIT_ORG_ID) {
@@ -24,6 +49,42 @@ if (env.LANGFUSE_INIT_ORG_ID) {
},
});
+ // Warn about partial configurations
+ const hasPublicKey = Boolean(env.LANGFUSE_INIT_PROJECT_PUBLIC_KEY);
+ const hasSecretKey = Boolean(env.LANGFUSE_INIT_PROJECT_SECRET_KEY);
+ const hasEmail = Boolean(env.LANGFUSE_INIT_USER_EMAIL);
+ const hasPassword = Boolean(env.LANGFUSE_INIT_USER_PASSWORD);
+
+ // Partial API key config
+ if (hasPublicKey !== hasSecretKey) {
+ const missingKey = hasPublicKey
+ ? "LANGFUSE_INIT_PROJECT_SECRET_KEY"
+ : "LANGFUSE_INIT_PROJECT_PUBLIC_KEY";
+ logger.warn(
+ `[Langfuse Init] Partial API key configuration: ${missingKey} is not set. ` +
+ `Both LANGFUSE_INIT_PROJECT_PUBLIC_KEY and LANGFUSE_INIT_PROJECT_SECRET_KEY must be set to create API keys.`,
+ );
+ }
+
+ // API keys without project ID
+ if ((hasPublicKey || hasSecretKey) && !env.LANGFUSE_INIT_PROJECT_ID) {
+ logger.warn(
+ `[Langfuse Init] LANGFUSE_INIT_PROJECT_ID is not set but API key variables are configured. ` +
+ `API keys will not be created. Set LANGFUSE_INIT_PROJECT_ID to enable API key creation.`,
+ );
+ }
+
+ // Partial user config
+ if (hasEmail !== hasPassword) {
+ const missingVar = hasEmail
+ ? "LANGFUSE_INIT_USER_PASSWORD"
+ : "LANGFUSE_INIT_USER_EMAIL";
+ logger.warn(
+ `[Langfuse Init] Partial user configuration: ${missingVar} is not set. ` +
+ `Both LANGFUSE_INIT_USER_EMAIL and LANGFUSE_INIT_USER_PASSWORD must be set to create a user.`,
+ );
+ }
+
// Create Project: Org -> Project
if (env.LANGFUSE_INIT_PROJECT_ID) {
let retentionDays: number | null = null;