Skip to content

πŸͺ’ Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(blob-export): gate legacy export sources for post-cutoff Cloud projects (#13627)

Niklas Semmler30d787c451b9
diff --git a/.env.dev.example b/.env.dev.example
index 2328305914..239001ad2a 100644
--- a/.env.dev.example
+++ b/.env.dev.example
@@ -62,6 +62,11 @@ NEXTAUTH_SECRET="secret"
# Langfuse Cloud Environment
NEXT_PUBLIC_LANGFUSE_CLOUD_REGION="DEV"
+# Dev-only: override the legacy blob-export cutoff date for local testing.
+# Set to a past date (e.g. 2020-01-01T00:00:00.000Z) to make every project
+# post-cutoff, or a future date (e.g. 2099-01-01T00:00:00.000Z) to grandfather
+# all projects. Must be a valid ISO 8601 datetime string. Leave unset in prod.
+# NEXT_PUBLIC_LANGFUSE_BLOB_EXPORT_CUTOFF=
# Langfuse experimental features
LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES="false"
diff --git a/fern/apis/server/definition/blob-storage-integrations.yml b/fern/apis/server/definition/blob-storage-integrations.yml
index 672a5c09a9..fbc59dce3c 100644
--- a/fern/apis/server/definition/blob-storage-integrations.yml
+++ b/fern/apis/server/definition/blob-storage-integrations.yml
@@ -131,7 +131,9 @@ types:
exportSource:
type: optional<BlobStorageExportSource>
docs: |
- Data to export. When omitted on update, the existing value is preserved; when omitted on create, the column default (`LEGACY_TRACES_OBSERVATIONS`) applies. Required when `exportFieldGroups` is provided.
+ Data to export. When omitted on update, the existing value is preserved. When omitted on create: pre-cutoff Cloud projects and self-hosted deployments fall back to `LEGACY_TRACES_OBSERVATIONS`; post-cutoff Cloud projects (created on or after 2026-05-20) auto-default to `OBSERVATIONS_V2`. Required when `exportFieldGroups` is provided.
+
+ **Cloud-only deprecation gate (effective 2026-05-20):** For projects created on or after 2026-05-20 on Langfuse Cloud, `LEGACY_TRACES_OBSERVATIONS` and `LEGACY_TRACES_AND_ENRICHED_OBSERVATIONS` are rejected with HTTP 400. Omitting `exportSource` on these projects silently defaults to `OBSERVATIONS_V2` rather than the schema column default. Use `OBSERVATIONS_V2` for all new integrations. Projects created before 2026-05-20 and self-hosted deployments are unaffected.
exportFieldGroups:
type: optional<list<BlobStorageExportFieldGroup>>
diff --git a/packages/shared/src/env.ts b/packages/shared/src/env.ts
index e4e33bfc90..f259980ba7 100644
--- a/packages/shared/src/env.ts
+++ b/packages/shared/src/env.ts
@@ -3,6 +3,10 @@ import { removeEmptyEnvVariables } from "./utils/environment";
const EnvSchema = z.object({
NEXT_PUBLIC_LANGFUSE_CLOUD_REGION: z.string().optional(),
+ // Dev-only override: set to an ISO datetime string to shift the legacy blob
+ // export cutoff for local testing (e.g. "2020-01-01T00:00:00.000Z" makes
+ // every project post-cutoff; "2099-01-01T00:00:00.000Z" grandfathers all).
+ NEXT_PUBLIC_LANGFUSE_BLOB_EXPORT_CUTOFF: z.iso.datetime().optional(),
NODE_ENV: z
.enum(["development", "test", "production"])
.default("development"),
diff --git a/packages/shared/src/features/analytics-integrations/blob-export-gate.ts b/packages/shared/src/features/analytics-integrations/blob-export-gate.ts
new file mode 100644
index 0000000000..d864416ad3
--- /dev/null
+++ b/packages/shared/src/features/analytics-integrations/blob-export-gate.ts
@@ -0,0 +1,38 @@
+// Business rules for the legacy blob export source deprecation gate.
+// This is a client-safe file that can be imported from @langfuse/shared.
+
+import { AnalyticsIntegrationExportSource } from "@prisma/client";
+
+// Cloud projects created on or after this instant cannot use legacy export sources.
+// NEXT_PUBLIC_LANGFUSE_BLOB_EXPORT_CUTOFF overrides the default for local dev testing.
+const _override = process.env.NEXT_PUBLIC_LANGFUSE_BLOB_EXPORT_CUTOFF
+ ? new Date(process.env.NEXT_PUBLIC_LANGFUSE_BLOB_EXPORT_CUTOFF)
+ : null;
+export const LEGACY_BLOB_EXPORT_CUTOFF =
+ _override && !isNaN(_override.getTime())
+ ? _override
+ : new Date("2026-05-20T00:00:00.000Z");
+
+// Internal enum values that are considered "legacy". satisfies ensures each
+// element remains a valid AnalyticsIntegrationExportSource β€” catches renames or
+// removals at compile time. Adding a new enum variant does NOT automatically
+// produce an error here; the list must be reviewed manually.
+export const LEGACY_BLOB_EXPORT_SOURCES = [
+ AnalyticsIntegrationExportSource.TRACES_OBSERVATIONS,
+ AnalyticsIntegrationExportSource.TRACES_OBSERVATIONS_EVENTS,
+] as const satisfies ReadonlyArray<AnalyticsIntegrationExportSource>;
+
+/**
+ * Returns true when a project may use legacy blob export sources.
+ * False means the project is post-cutoff Cloud and must use OBSERVATIONS_V2 (internal: EVENTS) only.
+ *
+ * Shared by the server guard (throws when false + legacy source) and the UI
+ * (hides legacy dropdown options when false) so the predicate lives once.
+ */
+export function isLegacyBlobExportAllowed(
+ projectCreatedAt: Date,
+ isCloud: boolean,
+): boolean {
+ if (!isCloud) return true;
+ return projectCreatedAt < LEGACY_BLOB_EXPORT_CUTOFF;
+}
diff --git a/packages/shared/src/features/analytics-integrations/index.ts b/packages/shared/src/features/analytics-integrations/index.ts
index 6d0ce31cf5..82e8b1cf45 100644
--- a/packages/shared/src/features/analytics-integrations/index.ts
+++ b/packages/shared/src/features/analytics-integrations/index.ts
@@ -7,6 +7,8 @@ import {
type ObservationFieldGroupFull,
} from "../../domain/observation-field-groups";
+export * from "./blob-export-gate";
+
export const EXPORT_SOURCE_OPTIONS: Array<{
value: AnalyticsIntegrationExportSource;
label: string;
diff --git a/turbo.json b/turbo.json
index 6acfdf9418..4a9231985f 100644
--- a/turbo.json
+++ b/turbo.json
@@ -1,6 +1,7 @@
{
"$schema": "https://turbo.build/schema.json",
"globalDependencies": [".env"],
+ "globalEnv": ["NEXT_PUBLIC_LANGFUSE_BLOB_EXPORT_CUTOFF"],
"envMode": "loose",
"tasks": {
"build": {
diff --git a/web/public/generated/api/openapi.yml b/web/public/generated/api/openapi.yml
index 047522354b..24f52fd090 100644
--- a/web/public/generated/api/openapi.yml
+++ b/web/public/generated/api/openapi.yml
@@ -7362,9 +7362,21 @@ components:
nullable: true
description: >-
Data to export. When omitted on update, the existing value is
- preserved; when omitted on create, the column default
- (`LEGACY_TRACES_OBSERVATIONS`) applies. Required when
- `exportFieldGroups` is provided.
+ preserved. When omitted on create: pre-cutoff Cloud projects and
+ self-hosted deployments fall back to `LEGACY_TRACES_OBSERVATIONS`;
+ post-cutoff Cloud projects (created on or after 2026-05-20)
+ auto-default to `OBSERVATIONS_V2`. Required when `exportFieldGroups`
+ is provided.
+
+
+ **Cloud-only deprecation gate (effective 2026-05-20):** For projects
+ created on or after 2026-05-20 on Langfuse Cloud,
+ `LEGACY_TRACES_OBSERVATIONS` and
+ `LEGACY_TRACES_AND_ENRICHED_OBSERVATIONS` are rejected with HTTP
+ 400. Omitting `exportSource` on these projects silently defaults to
+ `OBSERVATIONS_V2` rather than the schema column default. Use
+ `OBSERVATIONS_V2` for all new integrations. Projects created before
+ 2026-05-20 and self-hosted deployments are unaffected.
exportFieldGroups:
type: array
items:
diff --git a/web/src/__tests__/server/blob-storage-integration-api.servertest.ts b/web/src/__tests__/server/blob-storage-integration-api.servertest.ts
index bb5b070e35..24da5fb575 100644
--- a/web/src/__tests__/server/blob-storage-integration-api.servertest.ts
+++ b/web/src/__tests__/server/blob-storage-integration-api.servertest.ts
@@ -9,9 +9,16 @@ import {
createAndAddApiKeysToDb,
createBasicAuthHeader,
} from "@langfuse/shared/src/server";
-import { OBSERVATION_FIELD_GROUPS_FULL } from "@langfuse/shared";
+import {
+ OBSERVATION_FIELD_GROUPS_FULL,
+ LEGACY_BLOB_EXPORT_CUTOFF,
+} from "@langfuse/shared";
import { decrypt } from "@langfuse/shared/encryption";
+const MS_PER_DAY = 24 * 60 * 60 * 1000;
+const PRE_CUTOFF = new Date(LEGACY_BLOB_EXPORT_CUTOFF.getTime() - MS_PER_DAY);
+const POST_CUTOFF = new Date(LEGACY_BLOB_EXPORT_CUTOFF.getTime() + MS_PER_DAY);
+
// Schemas based on Fern schema definition
const BlobStorageIntegrationResponseSchema = z.object({
id: z.string(),
@@ -628,6 +635,24 @@ describe("Blob Storage Integrations API", () => {
});
describe("PUT/GET exportSource + exportFieldGroups behavior", () => {
+ // Pin projects to a pre-cutoff date so legacy-source tests remain valid
+ // once the clock crosses LEGACY_BLOB_EXPORT_CUTOFF (CI runs with
+ // NEXT_PUBLIC_LANGFUSE_CLOUD_REGION set, so the gate would otherwise
+ // reject LEGACY_TRACES_OBSERVATIONS for projects created at now()).
+ beforeAll(async () => {
+ await prisma.project.updateMany({
+ where: { id: { in: [testProject1Id, testProject2Id] } },
+ data: { createdAt: PRE_CUTOFF },
+ });
+ });
+
+ afterAll(async () => {
+ await prisma.project.updateMany({
+ where: { id: { in: [testProject1Id, testProject2Id] } },
+ data: { createdAt: new Date() },
+ });
+ });
+
afterEach(async () => {
await prisma.blobStorageIntegration.deleteMany({
where: {
@@ -1426,4 +1451,203 @@ describe("Blob Storage Integrations API", () => {
expect(result.body.message).toContain("Method not allowed");
});
});
+
+ describe("legacy blob export source cutoff gate", () => {
+ const basePayload = {
+ type: "S3" as const,
+ bucketName: "test-bucket",
+ endpoint: null,
+ region: "us-east-1",
+ accessKeyId: "AKIA123456789",
+ secretAccessKey: "secret123456789",
+ prefix: "exports/",
+ exportFrequency: "daily",
+ enabled: true,
+ forcePathStyle: false,
+ fileType: "JSONL",
+ exportMode: "FULL_HISTORY",
+ exportStartDate: null,
+ };
+
+ afterEach(() => {
+ vi.restoreAllMocks();
+ });
+
+ // All REST cutoff-gate tests rely on the CI server already running in Cloud
+ // mode (NEXT_PUBLIC_LANGFUSE_CLOUD_REGION is set in .env.dev.example). The
+ // makeAPICall goes over HTTP to a separate process whose env is frozen at
+ // boot, so any (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION mutation in
+ // the test process never reaches the server and would be dead code.
+
+ it("Cloud + pre-cutoff project + LEGACY_TRACES_OBSERVATIONS β†’ 200", async () => {
+ try {
+ await prisma.project.update({
+ where: { id: testProject1Id },
+ data: { createdAt: PRE_CUTOFF },
+ });
+ const result = await makeAPICall(
+ "PUT",
+ "/api/public/integrations/blob-storage",
+ {
+ ...basePayload,
+ projectId: testProject1Id,
+ exportSource: "LEGACY_TRACES_OBSERVATIONS",
+ },
+ createBasicAuthHeader(testApiKey, testApiSecretKey),
+ );
+ expect(result.status).toBe(200);
+ } finally {
+ await prisma.blobStorageIntegration.deleteMany({
+ where: { projectId: testProject1Id },
+ });
+ }
+ });
+
+ it("Cloud + post-cutoff project + LEGACY_TRACES_OBSERVATIONS β†’ 400", async () => {
+ try {
+ await prisma.project.update({
+ where: { id: testProject1Id },
+ data: { createdAt: POST_CUTOFF },
+ });
+ const result = await makeAPICall(
+ "PUT",
+ "/api/public/integrations/blob-storage",
+ {
+ ...basePayload,
+ projectId: testProject1Id,
+ exportSource: "LEGACY_TRACES_OBSERVATIONS",
+ },
+ createBasicAuthHeader(testApiKey, testApiSecretKey),
+ );
+ expect(result.status).toBe(400);
+ expect(result.body.message).toContain("OBSERVATIONS_V2");
+ } finally {
+ await prisma.project.update({
+ where: { id: testProject1Id },
+ data: { createdAt: new Date() },
+ });
+ }
+ });
+
+ it("Cloud + post-cutoff project + LEGACY_TRACES_AND_ENRICHED_OBSERVATIONS β†’ 400", async () => {
+ try {
+ await prisma.project.update({
+ where: { id: testProject1Id },
+ data: { createdAt: POST_CUTOFF },
+ });
+ const result = await makeAPICall(
+ "PUT",
+ "/api/public/integrations/blob-storage",
+ {
+ ...basePayload,
+ projectId: testProject1Id,
+ exportSource: "LEGACY_TRACES_AND_ENRICHED_OBSERVATIONS",
+ },
+ createBasicAuthHeader(testApiKey, testApiSecretKey),
+ );
+ expect(result.status).toBe(400);
+ expect(result.body.message).toContain("OBSERVATIONS_V2");
+ } finally {
+ await prisma.project.update({
+ where: { id: testProject1Id },
+ data: { createdAt: new Date() },
+ });
+ }
+ });
+
+ it("Cloud + post-cutoff project + OBSERVATIONS_V2 β†’ 200", async () => {
+ try {
+ await prisma.project.update({
+ where: { id: testProject1Id },
+ data: { createdAt: POST_CUTOFF },
+ });
+ const result = await makeAPICall(
+ "PUT",
+ "/api/public/integrations/blob-storage",
+ {
+ ...basePayload,
+ projectId: testProject1Id,
+ exportSource: "OBSERVATIONS_V2",
+ },
+ createBasicAuthHeader(testApiKey, testApiSecretKey),
+ );
+ expect(result.status).toBe(200);
+ } finally {
+ await prisma.project.update({
+ where: { id: testProject1Id },
+ data: { createdAt: new Date() },
+ });
+ await prisma.blobStorageIntegration.deleteMany({
+ where: { projectId: testProject1Id },
+ });
+ }
+ });
+ it("Cloud + post-cutoff project + no exportSource + CREATE β†’ defaults to OBSERVATIONS_V2", async () => {
+ // No existing row β†’ CREATE path: handler forces EVENTS (OBSERVATIONS_V2).
+ try {
+ await prisma.project.update({
+ where: { id: testProject1Id },
+ data: { createdAt: POST_CUTOFF },
+ });
+ const result = await makeAPICall(
+ "PUT",
+ "/api/public/integrations/blob-storage",
+ { ...basePayload, projectId: testProject1Id },
+ createBasicAuthHeader(testApiKey, testApiSecretKey),
+ );
+ expect(result.status).toBe(200);
+ expect(result.body.exportSource).toBe("OBSERVATIONS_V2");
+ } finally {
+ await prisma.project.update({
+ where: { id: testProject1Id },
+ data: { createdAt: new Date() },
+ });
+ await prisma.blobStorageIntegration.deleteMany({
+ where: { projectId: testProject1Id },
+ });
+ }
+ });
+
+ it("Cloud + post-cutoff project + no exportSource + UPDATE β†’ preserves existing value", async () => {
+ // Existing row with OBSERVATIONS_V2 β†’ UPDATE path: omitting exportSource
+ // must not overwrite the persisted value.
+ try {
+ await prisma.project.update({
+ where: { id: testProject1Id },
+ data: { createdAt: POST_CUTOFF },
+ });
+ await prisma.blobStorageIntegration.create({
+ data: {
+ projectId: testProject1Id,
+ type: "S3",
+ bucketName: "test-bucket",
+ region: "us-east-1",
+ prefix: "",
+ exportFrequency: "daily",
+ enabled: true,
+ forcePathStyle: false,
+ fileType: "JSONL",
+ exportMode: "FULL_HISTORY",
+ exportSource: "EVENTS",
+ },
+ });
+ const result = await makeAPICall(
+ "PUT",
+ "/api/public/integrations/blob-storage",
+ { ...basePayload, projectId: testProject1Id },
+ createBasicAuthHeader(testApiKey, testApiSecretKey),
+ );
+ expect(result.status).toBe(200);
+ expect(result.body.exportSource).toBe("OBSERVATIONS_V2");
+ } finally {
+ await prisma.project.update({
+ where: { id: testProject1Id },
+ data: { createdAt: new Date() },
+ });
+ await prisma.blobStorageIntegration.deleteMany({
+ where: { projectId: testProject1Id },
+ });
+ }
+ });
+ });
});
diff --git a/web/src/__tests__/server/blob-storage-integration-trpc.servertest.ts b/web/src/__tests__/server/blob-storage-integration-trpc.servertest.ts
index 8b3480a61f..f77f2b11b6 100644
--- a/web/src/__tests__/server/blob-storage-integration-trpc.servertest.ts
+++ b/web/src/__tests__/server/blob-storage-integration-trpc.servertest.ts
@@ -11,7 +11,15 @@ import {
QueueJobs,
StorageServiceFactory,
} from "@langfuse/shared/src/server";
-import { OBSERVATION_FIELD_GROUPS_FULL } from "@langfuse/shared";
+import {
+ OBSERVATION_FIELD_GROUPS_FULL,
+ LEGACY_BLOB_EXPORT_CUTOFF,
+} from "@langfuse/shared";
+import { env } from "@/src/env.mjs";
+
+const MS_PER_DAY = 24 * 60 * 60 * 1000;
+const PRE_CUTOFF = new Date(LEGACY_BLOB_EXPORT_CUTOFF.getTime() - MS_PER_DAY);
+const POST_CUTOFF = new Date(LEGACY_BLOB_EXPORT_CUTOFF.getTime() + MS_PER_DAY);
vi.mock("@langfuse/shared/src/server", async () => {
const actual = await vi.importActual("@langfuse/shared/src/server");
@@ -381,6 +389,10 @@ describe("Blob Storage Integration tRPC Router", () => {
it("rejects empty exportFieldGroups when exportSource is TRACES_OBSERVATIONS_EVENTS", async () => {
const { caller, project } = await prepare();
+ await prisma.project.update({
+ where: { id: project.id },
+ data: { createdAt: PRE_CUTOFF },
+ });
await expect(
caller.blobStorageIntegration.update({
@@ -394,6 +406,10 @@ describe("Blob Storage Integration tRPC Router", () => {
it("accepts empty exportFieldGroups when exportSource is TRACES_OBSERVATIONS", async () => {
const { caller, project } = await prepare();
+ await prisma.project.update({
+ where: { id: project.id },
+ data: { createdAt: PRE_CUTOFF },
+ });
await expect(
caller.blobStorageIntegration.update({
@@ -430,4 +446,94 @@ describe("Blob Storage Integration tRPC Router", () => {
]);
});
});
+
+ describe("legacy blob export source cutoff gate", () => {
+ afterEach(() => {
+ vi.restoreAllMocks();
+ });
+
+ it("Cloud + pre-cutoff project + legacy source β†’ allow", async () => {
+ const originalRegion = env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION;
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = "us";
+ try {
+ const { caller, project } = await prepare();
+ await prisma.project.update({
+ where: { id: project.id },
+ data: { createdAt: PRE_CUTOFF },
+ });
+ await expect(
+ caller.blobStorageIntegration.update({
+ projectId: project.id,
+ ...baseConfig,
+ exportSource: "TRACES_OBSERVATIONS" as const,
+ }),
+ ).resolves.not.toThrow();
+ } finally {
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = originalRegion;
+ }
+ });
+
+ it("Cloud + post-cutoff project + legacy source β†’ BAD_REQUEST", async () => {
+ const originalRegion = env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION;
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = "us";
+ try {
+ const { caller, project } = await prepare();
+ await prisma.project.update({
+ where: { id: project.id },
+ data: { createdAt: POST_CUTOFF },
+ });
+ await expect(
+ caller.blobStorageIntegration.update({
+ projectId: project.id,
+ ...baseConfig,
+ exportSource: "TRACES_OBSERVATIONS" as const,
+ }),
+ ).rejects.toMatchObject({ code: "BAD_REQUEST" });
+ } finally {
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = originalRegion;
+ }
+ });
+
+ it("Cloud + post-cutoff project + EVENTS β†’ allow", async () => {
+ const originalRegion = env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION;
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = "us";
+ try {
+ const { caller, project } = await prepare();
+ await prisma.project.update({
+ where: { id: project.id },
+ data: { createdAt: POST_CUTOFF },
+ });
+ await expect(
+ caller.blobStorageIntegration.update({
+ projectId: project.id,
+ ...baseConfig,
+ exportSource: "EVENTS" as const,
+ }),
+ ).resolves.not.toThrow();
+ } finally {
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = originalRegion;
+ }
+ });
+
+ it("self-hosted + post-cutoff project + legacy source β†’ allow (bypass)", async () => {
+ const originalRegion = env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION;
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = undefined;
+ try {
+ const { caller, project } = await prepare();
+ await prisma.project.update({
+ where: { id: project.id },
+ data: { createdAt: POST_CUTOFF },
+ });
+ await expect(
+ caller.blobStorageIntegration.update({
+ projectId: project.id,
+ ...baseConfig,
+ exportSource: "TRACES_OBSERVATIONS" as const,
+ }),
+ ).resolves.not.toThrow();
+ } finally {
+ (env as any).NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = originalRegion;
+ }
+ });
+ });
});
diff --git a/web/src/__tests__/server/unit/assertLegacyBlobExportSourceAllowed.servertest.ts b/web/src/__tests__/server/unit/assertLegacyBlobExportSourceAllowed.servertest.ts
new file mode 100644
index 0000000000..8e50a39ccf
--- /dev/null
+++ b/web/src/__tests__/server/unit/assertLegacyBlobExportSourceAllowed.servertest.ts
@@ -0,0 +1,123 @@
+import { describe, it, expect } from "vitest";
+import { assertLegacyBlobExportSourceAllowed } from "@/src/features/blobstorage-integration/server/assertLegacyBlobExportSourceAllowed";
+import {
+ isLegacyBlobExportAllowed,
+ LEGACY_BLOB_EXPORT_CUTOFF,
+} from "@langfuse/shared";
+
+const MS_PER_DAY = 24 * 60 * 60 * 1000;
+const PRE_CUTOFF = new Date(LEGACY_BLOB_EXPORT_CUTOFF.getTime() - MS_PER_DAY);
+const AT_CUTOFF = LEGACY_BLOB_EXPORT_CUTOFF;
+const POST_CUTOFF = new Date(LEGACY_BLOB_EXPORT_CUTOFF.getTime() + MS_PER_DAY);
+
+describe("assertLegacyBlobExportSourceAllowed", () => {
+ it("Cloud + EVENTS + pre-cutoff β†’ allow", () => {
+ expect(() =>
+ assertLegacyBlobExportSourceAllowed({
+ project: { createdAt: PRE_CUTOFF },
+ nextInternalExportSource: "EVENTS",
+ isCloud: true,
+ }),
+ ).not.toThrow();
+ });
+
+ it("Cloud + EVENTS + post-cutoff β†’ allow", () => {
+ expect(() =>
+ assertLegacyBlobExportSourceAllowed({
+ project: { createdAt: POST_CUTOFF },
+ nextInternalExportSource: "EVENTS",
+ isCloud: true,
+ }),
+ ).not.toThrow();
+ });
+
+ it("Cloud + TRACES_OBSERVATIONS + pre-cutoff β†’ allow (grandfathered)", () => {
+ expect(() =>
+ assertLegacyBlobExportSourceAllowed({
+ project: { createdAt: PRE_CUTOFF },
+ nextInternalExportSource: "TRACES_OBSERVATIONS",
+ isCloud: true,
+ }),
+ ).not.toThrow();
+ });
+
+ it("Cloud + TRACES_OBSERVATIONS + post-cutoff β†’ reject", () => {
+ expect(() =>
+ assertLegacyBlobExportSourceAllowed({
+ project: { createdAt: POST_CUTOFF },
+ nextInternalExportSource: "TRACES_OBSERVATIONS",
+ isCloud: true,
+ }),
+ ).toThrow();
+ });
+
+ it("Cloud + TRACES_OBSERVATIONS_EVENTS + post-cutoff β†’ reject", () => {
+ expect(() =>
+ assertLegacyBlobExportSourceAllowed({
+ project: { createdAt: POST_CUTOFF },
+ nextInternalExportSource: "TRACES_OBSERVATIONS_EVENTS",
+ isCloud: true,
+ }),
+ ).toThrow();
+ });
+
+ it("self-hosted + EVENTS + post-cutoff β†’ allow (bypass)", () => {
+ expect(() =>
+ assertLegacyBlobExportSourceAllowed({
+ project: { createdAt: POST_CUTOFF },
+ nextInternalExportSource: "EVENTS",
+ isCloud: false,
+ }),
+ ).not.toThrow();
+ });
+
+ it("self-hosted + TRACES_OBSERVATIONS + pre-cutoff β†’ allow (bypass)", () => {
+ expect(() =>
+ assertLegacyBlobExportSourceAllowed({
+ project: { createdAt: PRE_CUTOFF },
+ nextInternalExportSource: "TRACES_OBSERVATIONS",
+ isCloud: false,
+ }),
+ ).not.toThrow();
+ });
+
+ it("self-hosted + TRACES_OBSERVATIONS + post-cutoff β†’ allow (bypass)", () => {
+ expect(() =>
+ assertLegacyBlobExportSourceAllowed({
+ project: { createdAt: POST_CUTOFF },
+ nextInternalExportSource: "TRACES_OBSERVATIONS",
+ isCloud: false,
+ }),
+ ).not.toThrow();
+ });
+
+ it("boundary: project.createdAt === cutoff β†’ reject (>= semantics)", () => {
+ expect(() =>
+ assertLegacyBlobExportSourceAllowed({
+ project: { createdAt: AT_CUTOFF },
+ nextInternalExportSource: "TRACES_OBSERVATIONS",
+ isCloud: true,
+ }),
+ ).toThrow();
+ });
+});
+
+describe("isLegacyBlobExportAllowed predicate", () => {
+ it("self-hosted always returns true", () => {
+ expect(isLegacyBlobExportAllowed(POST_CUTOFF, false)).toBe(true);
+ expect(isLegacyBlobExportAllowed(AT_CUTOFF, false)).toBe(true);
+ expect(isLegacyBlobExportAllowed(PRE_CUTOFF, false)).toBe(true);
+ });
+
+ it("Cloud + pre-cutoff β†’ true (grandfathered)", () => {
+ expect(isLegacyBlobExportAllowed(PRE_CUTOFF, true)).toBe(true);
+ });
+
+ it("Cloud + post-cutoff β†’ false", () => {
+ expect(isLegacyBlobExportAllowed(POST_CUTOFF, true)).toBe(false);
+ });
+
+ it("Cloud + exactly at cutoff β†’ false (>= semantics)", () => {
+ expect(isLegacyBlobExportAllowed(AT_CUTOFF, true)).toBe(false);
+ });
+});
diff --git a/web/src/env.mjs b/web/src/env.mjs
index a682ef968d..3222a4f022 100644
--- a/web/src/env.mjs
+++ b/web/src/env.mjs
@@ -482,6 +482,7 @@ export const env = createEnv({
NEXT_PUBLIC_LANGFUSE_CLOUD_REGION: z
.enum(["US", "EU", "STAGING", "DEV", "HIPAA", "JP"])
.optional(),
+ NEXT_PUBLIC_LANGFUSE_BLOB_EXPORT_CUTOFF: z.iso.datetime().optional(),
NEXT_PUBLIC_DEMO_PROJECT_ID: z.string().optional(),
NEXT_PUBLIC_DEMO_ORG_ID: z.string().optional(),
NEXT_PUBLIC_SIGN_UP_DISABLED: z.enum(["true", "false"]).default("false"),
@@ -513,6 +514,8 @@ export const env = createEnv({
NEXTAUTH_URL: process.env.NEXTAUTH_URL,
NEXT_PUBLIC_LANGFUSE_CLOUD_REGION:
process.env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION,
+ NEXT_PUBLIC_LANGFUSE_BLOB_EXPORT_CUTOFF:
+ process.env.NEXT_PUBLIC_LANGFUSE_BLOB_EXPORT_CUTOFF,
NEXT_PUBLIC_SIGN_UP_DISABLED: process.env.NEXT_PUBLIC_SIGN_UP_DISABLED,
LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES:
process.env.LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES,
diff --git a/web/src/features/blobstorage-integration/blobstorage-integration-router.ts b/web/src/features/blobstorage-integration/blobstorage-integration-router.ts
index eed52769a5..6558ec5f0c 100644
--- a/web/src/features/blobstorage-integration/blobstorage-integration-router.ts
+++ b/web/src/features/blobstorage-integration/blobstorage-integration-router.ts
@@ -12,7 +12,9 @@ import {
validateExportFieldGroups,
} from "@/src/features/blobstorage-integration/validation";
import { upsertBlobStorageIntegration } from "@/src/features/blobstorage-integration/service";
+import { assertLegacyBlobExportSourceAllowed } from "@/src/features/blobstorage-integration/server/assertLegacyBlobExportSourceAllowed";
import { TRPCError } from "@trpc/server";
+import { env } from "@/src/env.mjs";
import {
logger,
BlobStorageIntegrationProcessingQueue,
@@ -83,6 +85,19 @@ export const blobStorageIntegrationRouter = createTRPCRouter({
projectId: input.projectId,
scope: "integrations:CRUD",
});
+
+ if (input.exportSource) {
+ const project = await ctx.prisma.project.findUniqueOrThrow({
+ where: { id: input.projectId },
+ select: { createdAt: true },
+ });
+ assertLegacyBlobExportSourceAllowed({
+ project,
+ nextInternalExportSource: input.exportSource,
+ isCloud: Boolean(env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION),
+ });
+ }
+
await auditLog({
session: ctx.session,
action: "update",
diff --git a/web/src/features/blobstorage-integration/server/assertLegacyBlobExportSourceAllowed.ts b/web/src/features/blobstorage-integration/server/assertLegacyBlobExportSourceAllowed.ts
new file mode 100644
index 0000000000..756a26b16c
--- /dev/null
+++ b/web/src/features/blobstorage-integration/server/assertLegacyBlobExportSourceAllowed.ts
@@ -0,0 +1,29 @@
+import {
+ InvalidRequestError,
+ isLegacyBlobExportAllowed,
+ LEGACY_BLOB_EXPORT_SOURCES,
+} from "@langfuse/shared";
+import { type AnalyticsIntegrationExportSource } from "@langfuse/shared/src/db";
+
+export function assertLegacyBlobExportSourceAllowed({
+ project,
+ nextInternalExportSource,
+ isCloud,
+}: {
+ project: { createdAt: Date };
+ nextInternalExportSource: AnalyticsIntegrationExportSource;
+ isCloud: boolean;
+}): void {
+ if (
+ !(LEGACY_BLOB_EXPORT_SOURCES as ReadonlyArray<string>).includes(
+ nextInternalExportSource,
+ )
+ )
+ return; // OBSERVATIONS_V2 (internal: EVENTS) is always allowed.
+
+ if (isLegacyBlobExportAllowed(project.createdAt, isCloud)) return;
+
+ throw new InvalidRequestError(
+ "Legacy export sources are not available for Cloud projects created on or after 2026-05-20. Use 'OBSERVATIONS_V2' instead.",
+ );
+}
diff --git a/web/src/features/blobstorage-integration/service.ts b/web/src/features/blobstorage-integration/service.ts
index 924ff81aeb..bcb865a3cb 100644
--- a/web/src/features/blobstorage-integration/service.ts
+++ b/web/src/features/blobstorage-integration/service.ts
@@ -3,8 +3,8 @@ import {
BlobStorageExportMode,
BlobStorageIntegrationType,
InvalidRequestError,
+ AnalyticsIntegrationExportSource,
type BlobStorageIntegrationFileType,
- type AnalyticsIntegrationExportSource,
type ObservationFieldGroupFull,
} from "@langfuse/shared";
import { encrypt } from "@langfuse/shared/encryption";
@@ -52,6 +52,11 @@ export async function upsertBlobStorageIntegration(params: {
prisma: PrismaClient;
projectId: string;
data: UpsertBlobStorageIntegrationInput;
+ // When true and no existing row is found inside the transaction, the CREATE
+ // branch uses EVENTS instead of the Prisma column default (TRACES_OBSERVATIONS).
+ // Evaluated inside the transaction so the row-state check and the INSERT are
+ // atomic β€” no TOCTOU window.
+ forceEventsOnCreate?: boolean;
}) {
const { prisma, projectId, data } = params;
@@ -110,10 +115,26 @@ export async function upsertBlobStorageIntegration(params: {
? encrypt(data.secretAccessKey)
: null;
+ // exportSource for the CREATE payload. The !existing guard was previously
+ // here, but it created a residual TOCTOU: READ COMMITTED isolation means
+ // tx.findUnique and tx.upsert take independent snapshots, so a concurrent
+ // DELETE between the two could leave createExportSource = undefined and let
+ // Postgres apply the @default(TRACES_OBSERVATIONS) column default on INSERT.
+ // Dropping the guard is safe: ON CONFLICT atomically decides CREATE vs UPDATE
+ // at INSERT time regardless of what findUnique saw. UPDATE uses
+ // writeData.exportSource (undefined β†’ Prisma omits the column β†’ preserves
+ // the existing value), so the caller intent is always honored on both paths.
+ const createExportSource =
+ data.exportSource ??
+ (params.forceEventsOnCreate
+ ? AnalyticsIntegrationExportSource.EVENTS
+ : undefined);
+
return tx.blobStorageIntegration.upsert({
where: { projectId },
create: {
...writeData,
+ exportSource: createExportSource,
projectId,
secretAccessKey: encryptedSecret,
},
diff --git a/web/src/pages/api/public/integrations/blob-storage/index.ts b/web/src/pages/api/public/integrations/blob-storage/index.ts
index c6b2379ae4..658991f135 100644
--- a/web/src/pages/api/public/integrations/blob-storage/index.ts
+++ b/web/src/pages/api/public/integrations/blob-storage/index.ts
@@ -16,9 +16,12 @@ import {
LangfuseNotFoundError,
UnauthorizedError,
ForbiddenError,
+ isLegacyBlobExportAllowed,
} from "@langfuse/shared";
import { upsertBlobStorageIntegration } from "@/src/features/blobstorage-integration/service";
+import { assertLegacyBlobExportSourceAllowed } from "@/src/features/blobstorage-integration/server/assertLegacyBlobExportSourceAllowed";
import { auditLog } from "@/src/features/audit-logs/auditLog";
+import { env } from "@/src/env.mjs";
export default withMiddlewares({
GET: handleGetBlobStorageIntegrations,
@@ -152,12 +155,24 @@ async function handleUpsertBlobStorageIntegration(
// Check if the project exists and belongs to the organization
const project = await prisma.project.findUnique({
where: { id: validatedData.projectId },
- select: { id: true, orgId: true },
+ select: { id: true, orgId: true, createdAt: true },
});
if (!project || project.orgId !== authCheck.scope.orgId) {
throw new LangfuseNotFoundError("Project not found");
}
+ const isCloud = Boolean(env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION);
+
+ if (validatedData.exportSource) {
+ assertLegacyBlobExportSourceAllowed({
+ project,
+ nextInternalExportSource: toInternalExportSource(
+ validatedData.exportSource,
+ ),
+ isCloud,
+ });
+ }
+
await auditLog({
action: "update",
resourceType: "blobStorageIntegration",
@@ -169,6 +184,12 @@ async function handleUpsertBlobStorageIntegration(
const integration = await upsertBlobStorageIntegration({
prisma,
projectId: validatedData.projectId,
+ // When exportSource is absent and the project is post-cutoff Cloud, have
+ // the service substitute EVENTS on CREATE inside its own transaction β€”
+ // eliminating the TOCTOU window that a pre-flight findUnique would create.
+ forceEventsOnCreate:
+ validatedData.exportSource == null &&
+ !isLegacyBlobExportAllowed(project.createdAt, isCloud),
data: {
type: validatedData.type,
bucketName: validatedData.bucketName,
diff --git a/web/src/pages/project/[projectId]/settings/integrations/blobstorage.tsx b/web/src/pages/project/[projectId]/settings/integrations/blobstorage.tsx
index 1875101edf..a5c1ba28d1 100644
--- a/web/src/pages/project/[projectId]/settings/integrations/blobstorage.tsx
+++ b/web/src/pages/project/[projectId]/settings/integrations/blobstorage.tsx
@@ -55,8 +55,11 @@ import {
EXPORT_FIELD_GROUP_OPTIONS,
OBSERVATION_FIELD_GROUPS_FULL,
type ObservationFieldGroupFull,
+ LEGACY_BLOB_EXPORT_SOURCES,
+ isLegacyBlobExportAllowed,
} from "@langfuse/shared";
import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";
+import { useQueryProject } from "@/src/features/projects/hooks";
import { useV4Beta } from "@/src/features/events/hooks/useV4Beta";
import { Info, ExternalLink } from "lucide-react";
@@ -233,12 +236,28 @@ const BlobStorageIntegrationSettingsForm = ({
const capture = usePostHogClientCapture();
const { isLangfuseCloud } = useLangfuseCloudRegion();
const { isBetaEnabled } = useV4Beta();
+ const { project } = useQueryProject();
const [integrationType, setIntegrationType] =
useState<BlobStorageIntegrationType>(BlobStorageIntegrationType.S3);
// Check if this is a self-hosted instance (no cloud region set)
const isSelfHosted = !isLangfuseCloud;
+ // Post-cutoff Cloud projects may only use OBSERVATIONS_V2 (EVENTS).
+ const isPostCutoffCloud =
+ project?.createdAt != null &&
+ !isLegacyBlobExportAllowed(new Date(project.createdAt), isLangfuseCloud);
+
+ // Options shown in the dropdown. Legacy options are always hidden for
+ // post-cutoff Cloud projects, including any previously-persisted value.
+ const availableExportSourceOptions = EXPORT_SOURCE_OPTIONS.filter(
+ (opt) =>
+ !isPostCutoffCloud ||
+ !(LEGACY_BLOB_EXPORT_SOURCES as ReadonlyArray<string>).includes(
+ opt.value,
+ ),
+ );
+
const blobStorageForm = useForm({
resolver: zodResolver(blobStorageIntegrationFormSchema),
defaultValues: {
@@ -259,11 +278,12 @@ const BlobStorageIntegrationSettingsForm = ({
fileType: state?.fileType || BlobStorageIntegrationFileType.JSONL,
exportMode: state?.exportMode || BlobStorageExportMode.FULL_HISTORY,
exportStartDate: state?.exportStartDate || null,
- exportSource:
- state?.exportSource ||
- (isBetaEnabled
- ? AnalyticsIntegrationExportSource.EVENTS
- : AnalyticsIntegrationExportSource.TRACES_OBSERVATIONS),
+ exportSource: isPostCutoffCloud
+ ? AnalyticsIntegrationExportSource.EVENTS
+ : state?.exportSource ||
+ (isBetaEnabled
+ ? AnalyticsIntegrationExportSource.EVENTS
+ : AnalyticsIntegrationExportSource.TRACES_OBSERVATIONS),
exportFieldGroups:
(state?.exportFieldGroups as ObservationFieldGroupFull[]) ?? [
...OBSERVATION_FIELD_GROUPS_FULL,
@@ -293,11 +313,12 @@ const BlobStorageIntegrationSettingsForm = ({
fileType: state?.fileType || BlobStorageIntegrationFileType.JSONL,
exportMode: state?.exportMode || BlobStorageExportMode.FULL_HISTORY,
exportStartDate: state?.exportStartDate || null,
- exportSource:
- state?.exportSource ||
- (isBetaEnabled
- ? AnalyticsIntegrationExportSource.EVENTS
- : AnalyticsIntegrationExportSource.TRACES_OBSERVATIONS),
+ exportSource: isPostCutoffCloud
+ ? AnalyticsIntegrationExportSource.EVENTS
+ : state?.exportSource ||
+ (isBetaEnabled
+ ? AnalyticsIntegrationExportSource.EVENTS
+ : AnalyticsIntegrationExportSource.TRACES_OBSERVATIONS),
exportFieldGroups:
(state?.exportFieldGroups as ObservationFieldGroupFull[]) ?? [
...OBSERVATION_FIELD_GROUPS_FULL,
@@ -714,17 +735,25 @@ const BlobStorageIntegrationSettingsForm = ({
</SelectTrigger>
</FormControl>
<SelectContent>
- {EXPORT_SOURCE_OPTIONS.map((option) => (
+ {availableExportSourceOptions.map((option) => (
<SelectItem key={option.value} value={option.value}>
{option.label}
</SelectItem>
))}
</SelectContent>
</Select>
- <FormDescription>
- Choose which data sources to export to blob storage. Scores
- are always included.
- </FormDescription>
+ {isPostCutoffCloud ? (
+ <FormDescription>
+ Legacy export sources are not available for projects created
+ on or after May 20, 2026. Use &quot;Enriched
+ observations&quot; instead.
+ </FormDescription>
+ ) : (
+ <FormDescription>
+ Choose which data sources to export to blob storage. Scores
+ are always included.
+ </FormDescription>
+ )}
<FormMessage />
</FormItem>
)}
diff --git a/web/src/server/auth.ts b/web/src/server/auth.ts
index 641d9f1588..f7889e3c7f 100644
--- a/web/src/server/auth.ts
+++ b/web/src/server/auth.ts
@@ -886,6 +886,7 @@ export async function getAuthOptions(): Promise<NextAuthOptions> {
string,
unknown
>) ?? {},
+ createdAt: project.createdAt.toISOString(),
};
})
// Only include projects where the user has the required role
diff --git a/web/types/next-auth.d.ts b/web/types/next-auth.d.ts
index 2c0635c91f..0bce3dbc9f 100644
--- a/web/types/next-auth.d.ts
+++ b/web/types/next-auth.d.ts
@@ -53,6 +53,7 @@ declare module "next-auth" {
hasTraces: PrismaProject["hasTraces"];
metadata: Record<string, unknown>;
role: Role; // include only projects where user has a role
+ createdAt: string; // iso datetime string β€” JWT does not support Date objects
}[];
}[];
featureFlags: Flags;