🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
feat(blob-storage): Google Cloud Storage export target (service account key or ADC) (#18158)
Pushkar Kolhe68afc60c90d8
diff --git a/fern/apis/server/definition/blob-storage-integrations.yml b/fern/apis/server/definition/blob-storage-integrations.ymlindex d1d0a58033..e384b3a0a2 100644--- a/fern/apis/server/definition/blob-storage-integrations.yml+++ b/fern/apis/server/definition/blob-storage-integrations.yml@@ -41,6 +41,7 @@ types:- S3- S3_COMPATIBLE- AZURE_BLOB_STORAGE+ - GOOGLE_CLOUD_STORAGEBlobStorageIntegrationFileType:docs: |@@ -109,19 +110,22 @@ types:type: BlobStorageIntegrationTypebucketName:type: string- docs: Name of the storage bucket. For AZURE_BLOB_STORAGE, must be a valid Azure container name (3-63 chars, lowercase letters, numbers, and hyphens only, must start and end with a letter or number, no consecutive hyphens).+ docs: Name of the storage bucket. For AZURE_BLOB_STORAGE, must be a valid Azure container name (3-63 chars, lowercase letters, numbers, and hyphens only, must start and end with a letter or number, no consecutive hyphens). For GOOGLE_CLOUD_STORAGE with default credentials, the bucket must be listed in `LANGFUSE_BLOB_STORAGE_GCS_ALLOWED_BUCKETS`.endpoint:type: optional<string>- docs: Custom endpoint URL (required for S3_COMPATIBLE type)+ docs: Custom endpoint URL (required for S3_COMPATIBLE type). Ignored for GOOGLE_CLOUD_STORAGE.region:type: string- docs: "Storage region used by S3-compatible clients (AWS, GCS, Cloudflare R2, MinIO, Azure location IDs such as eastus, OCI). Leading and trailing whitespace is removed. The remaining value must be 1-63 letters, numbers, or hyphens, and cannot start or end with a hyphen. Examples: us-east-1, europe-west1, eastus, auto."+ docs: "Storage region used by S3-compatible clients (AWS, GCS, Cloudflare R2, MinIO, Azure location IDs such as eastus, OCI). Leading and trailing whitespace is removed. The remaining value must be 1-63 letters, numbers, or hyphens, and cannot start or end with a hyphen. Examples: us-east-1, europe-west1, eastus, auto. Not used by GOOGLE_CLOUD_STORAGE; pass auto."accessKeyId:type: optional<string>- docs: Access key ID for authentication+ docs: Access key ID for authentication. Not used for GOOGLE_CLOUD_STORAGE.secretAccessKey:type: optional<string>- docs: Secret access key for authentication (will be encrypted when stored)+ docs: |+ Secret access key for authentication (will be encrypted when stored). When omitted on update, the stored secret is kept, unless the type changes between GOOGLE_CLOUD_STORAGE and another type.++ For GOOGLE_CLOUD_STORAGE, a GCP service account JSON key. On self-hosted deployments, pass `__GCS_DEFAULT_CREDENTIALS__` instead to use the deployment's Application Default Credentials; the bucket must then be listed in `LANGFUSE_BLOB_STORAGE_GCS_ALLOWED_BUCKETS`. Default credentials are not available on Langfuse Cloud.prefix:type: optional<string>docs: Path prefix for exported files (must end with forward slash if provided)diff --git a/packages/shared/prisma/migrations/20261007122058_add_gcs_blob_storage_integration_type/migration.sql b/packages/shared/prisma/migrations/20261007122058_add_gcs_blob_storage_integration_type/migration.sqlnew file mode 100644index 0000000000..99c618c57b--- /dev/null+++ b/packages/shared/prisma/migrations/20261007122058_add_gcs_blob_storage_integration_type/migration.sql@@ -0,0 +1,2 @@+-- AlterEnum+ALTER TYPE "BlobStorageIntegrationType" ADD VALUE IF NOT EXISTS 'GOOGLE_CLOUD_STORAGE';diff --git a/packages/shared/prisma/schema.prisma b/packages/shared/prisma/schema.prismaindex 78589707df..eae9f418c6 100644--- a/packages/shared/prisma/schema.prisma+++ b/packages/shared/prisma/schema.prisma@@ -1498,6 +1498,7 @@ enum BlobStorageIntegrationType {S3S3_COMPATIBLEAZURE_BLOB_STORAGE+ GOOGLE_CLOUD_STORAGE@@map("BlobStorageIntegrationType")}diff --git a/packages/shared/src/env.ts b/packages/shared/src/env.tsindex e4bb3bd8de..cca2ad5498 100644--- a/packages/shared/src/env.ts+++ b/packages/shared/src/env.ts@@ -551,6 +551,22 @@ const EnvSchema = z.object({.transform((s) =>s ? s.split(",").map((s) => s.toLowerCase().trim()) : [],),+ // Buckets that keyless GOOGLE_CLOUD_STORAGE blob exports (default credentials,+ // no service account key) may write to. Those run as the deployment's own GCP+ // identity (ADC), so without this allowlist any project owner could export into+ // any bucket that identity can write. Empty disables keyless GCS exports;+ // exports with a service account key are unaffected.+ LANGFUSE_BLOB_STORAGE_GCS_ALLOWED_BUCKETS: z+ .string()+ .optional()+ .transform((s) =>+ s+ ? s+ .split(",")+ .map((s) => s.toLowerCase().trim())+ .filter(Boolean)+ : [],+ ),LANGFUSE_SSO_DISCOVERY_WHITELISTED_IPS: z.string().optional()diff --git a/packages/shared/src/interfaces/customLLMProviderConfigSchemas.ts b/packages/shared/src/interfaces/customLLMProviderConfigSchemas.tsindex c173adc230..2ebe141321 100644--- a/packages/shared/src/interfaces/customLLMProviderConfigSchemas.ts+++ b/packages/shared/src/interfaces/customLLMProviderConfigSchemas.ts@@ -8,6 +8,11 @@ export const BEDROCK_USE_DEFAULT_CREDENTIALS =export const VERTEXAI_USE_DEFAULT_CREDENTIALS ="__VERTEXAI_DEFAULT_CREDENTIALS__";+// Sentinel the blob-storage form sends as the GCS secret to request the+// deployment's default credentials (ADC) instead of a service account key.+// Never persisted: a keyless GCS integration stores secretAccessKey = null.+export const GCS_USE_DEFAULT_CREDENTIALS = "__GCS_DEFAULT_CREDENTIALS__";+export const BedrockConfigSchema = z.object({ region: z.string() });export type BedrockConfig = z.infer<typeof BedrockConfigSchema>;diff --git a/packages/shared/src/server/services/StorageService.test.ts b/packages/shared/src/server/services/StorageService.test.tsindex 19ca8bbf85..9e5b8b2d1c 100644--- a/packages/shared/src/server/services/StorageService.test.ts+++ b/packages/shared/src/server/services/StorageService.test.ts@@ -395,6 +395,56 @@ describe("GoogleCloudStorageService signed-URL retry", () => {});});+describe("StorageServiceFactory GCS credentials", () => {+ const original = env.LANGFUSE_GOOGLE_CLOUD_STORAGE_CREDENTIALS;+ afterEach(() => {+ env.LANGFUSE_GOOGLE_CLOUD_STORAGE_CREDENTIALS = original;+ });++ const keyFilenameOf = (service: unknown) =>+ (service as { storage: { authClient: { keyFilename?: string } } }).storage+ .authClient.keyFilename;++ it("uses ADC, not the deployment storage key, when GCS is selected explicitly without credentials", () => {+ env.LANGFUSE_GOOGLE_CLOUD_STORAGE_CREDENTIALS = "/etc/deployment-key.json";+ const service = StorageServiceFactory.getInstance({+ accessKeyId: undefined,+ secretAccessKey: undefined,+ bucketName: "test-bucket",+ endpoint: undefined,+ region: undefined,+ forcePathStyle: false,+ useGoogleCloudStorage: true,+ awsSse: undefined,+ awsSseKmsKeyId: undefined,+ });++ expect(keyFilenameOf(service)).toBeUndefined();+ });++ it("uses the deployment storage key when GCS is selected by env", () => {+ env.LANGFUSE_GOOGLE_CLOUD_STORAGE_CREDENTIALS = "/etc/deployment-key.json";+ const originalUseGcs = env.LANGFUSE_USE_GOOGLE_CLOUD_STORAGE;+ env.LANGFUSE_USE_GOOGLE_CLOUD_STORAGE = "true";+ try {+ const service = StorageServiceFactory.getInstance({+ accessKeyId: undefined,+ secretAccessKey: undefined,+ bucketName: "test-bucket",+ endpoint: undefined,+ region: undefined,+ forcePathStyle: false,+ awsSse: undefined,+ awsSseKmsKeyId: undefined,+ });++ expect(keyFilenameOf(service)).toBe("/etc/deployment-key.json");+ } finally {+ env.LANGFUSE_USE_GOOGLE_CLOUD_STORAGE = originalUseGcs;+ }+ });+});+/*** Source-stream errors on GCS uploads must reject the awaited upload instead* of escaping as an uncaught 'error' event. `.pipe().on("error")` onlydiff --git a/packages/shared/src/server/services/StorageService.ts b/packages/shared/src/server/services/StorageService.tsindex 8820b78f40..425037dc0f 100644--- a/packages/shared/src/server/services/StorageService.ts+++ b/packages/shared/src/server/services/StorageService.ts@@ -383,16 +383,18 @@ export class StorageServiceFactory {? params.useGoogleCloudStorage: env.LANGFUSE_USE_GOOGLE_CLOUD_STORAGE === "true") {- // connectionValidation is intentionally not applied here: GCS is selected- // by deployment env for Langfuse-owned storage, not by user-configured- // blob storage integrations. Those callers force useGoogleCloudStorage to- // false. Add SDK-specific connection-time validation before exposing GCS- // as a user-configurable blob export endpoint.+ // connectionValidation is not applied to GCS: the endpoint is always+ // Google's, never user-supplied. Only env-selected (Langfuse-owned)+ // storage falls back to LANGFUSE_GOOGLE_CLOUD_STORAGE_CREDENTIALS;+ // callers that select GCS explicitly (blob storage integrations) get+ // exactly the credentials they pass, or ADC when none.const googleParams = {...params,googleCloudCredentials:- params.googleCloudCredentials ||- env.LANGFUSE_GOOGLE_CLOUD_STORAGE_CREDENTIALS,+ params.useGoogleCloudStorage !== undefined+ ? params.googleCloudCredentials+ : params.googleCloudCredentials ||+ env.LANGFUSE_GOOGLE_CLOUD_STORAGE_CREDENTIALS,};return new GoogleCloudStorageService(googleParams);}diff --git a/packages/shared/src/server/services/blobStorageEndpointValidation.test.ts b/packages/shared/src/server/services/blobStorageEndpointValidation.test.tsindex 12e6020dbd..a86bed11e9 100644--- a/packages/shared/src/server/services/blobStorageEndpointValidation.test.ts+++ b/packages/shared/src/server/services/blobStorageEndpointValidation.test.ts@@ -1,6 +1,10 @@-import { describe, it, expect } from "vitest";+import { afterEach, describe, it, expect } from "vitest";import { OutboundUrlValidationError, parseOutboundUrl } from "../outbound-url";-import { validateBlobStorageEndpoint } from "./blobStorageEndpointValidation";+import {+ assertGcsBlobStorageBucketAllowed,+ validateBlobStorageEndpoint,+} from "./blobStorageEndpointValidation";+import { env } from "../../env";// Non-empty whitelist turns on validation in a non-cloud (DEV) deployment; the// entries are an *allow* list, so an endpoint outside them is still checked.@@ -59,3 +63,52 @@ describe("validateBlobStorageEndpoint", () => {).resolves.toBeUndefined();});});++describe("assertGcsBlobStorageBucketAllowed", () => {+ const original = {+ buckets: env.LANGFUSE_BLOB_STORAGE_GCS_ALLOWED_BUCKETS,+ region: env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION,+ };+ const setEnv = (buckets: string[], region?: string) => {+ env.LANGFUSE_BLOB_STORAGE_GCS_ALLOWED_BUCKETS = buckets;+ env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = region as never;+ };+ const codeOf = (fn: () => void) => {+ try {+ fn();+ } catch (error) {+ return (error as { code?: string }).code;+ }+ return undefined;+ };++ afterEach(() => setEnv(original.buckets, original.region));++ it("is disabled when no buckets are allowlisted", () => {+ setEnv([]);+ expect(codeOf(() => assertGcsBlobStorageBucketAllowed("any"))).toBe(+ "gcs-bucket-not-allowed",+ );+ });++ it("allows an allowlisted bucket, case- and whitespace-insensitive", () => {+ setEnv(["sc-langfuse-staging"]);+ expect(() =>+ assertGcsBlobStorageBucketAllowed(" SC-Langfuse-Staging "),+ ).not.toThrow();+ });++ it("rejects a bucket outside the allowlist", () => {+ setEnv(["sc-langfuse-staging"]);+ expect(+ codeOf(() => assertGcsBlobStorageBucketAllowed("other-bucket")),+ ).toBe("gcs-bucket-not-allowed");+ });++ it("is never available on Langfuse Cloud, even if a bucket is listed", () => {+ setEnv(["sc-langfuse-staging"], "US");+ expect(+ codeOf(() => assertGcsBlobStorageBucketAllowed("sc-langfuse-staging")),+ ).toBe("gcs-not-allowed");+ });+});diff --git a/packages/shared/src/server/services/blobStorageEndpointValidation.ts b/packages/shared/src/server/services/blobStorageEndpointValidation.tsindex 34234c6ed8..c8a3b40e42 100644--- a/packages/shared/src/server/services/blobStorageEndpointValidation.ts+++ b/packages/shared/src/server/services/blobStorageEndpointValidation.ts@@ -89,6 +89,44 @@ export async function validateBlobStorageEndpoint(}}+// Rejection of a keyless GCS export. The worker classifies it by name as a+// bucket fault, so the integration is disabled instead of retried.+class GcsBucketNotAllowedError extends Error {+ constructor(+ readonly code: "gcs-bucket-not-allowed" | "gcs-not-allowed",+ message: string,+ ) {+ super(message);+ this.name = "GcsBucketNotAllowedError";+ }+}++/**+ * Keyless GOOGLE_CLOUD_STORAGE blob exports (no service account key stored)+ * authenticate as the deployment's own GCP identity (ADC), so the bucket is the+ * only thing a project owner controls. Restrict it to operator-approved buckets.+ * Self-hosted only: on Langfuse Cloud the ADC identity is Langfuse's own.+ * Exports with a customer service account key are scoped by that key instead,+ * like the Vertex AI LLM connection, and need no allowlist.+ */+export function assertGcsBlobStorageBucketAllowed(bucketName: string): void {+ if (env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION) {+ throw new GcsBucketNotAllowedError(+ "gcs-not-allowed",+ "Google Cloud Storage exports with default credentials are only available on self-hosted deployments. Provide a service account key instead.",+ );+ }+ const allowed = env.LANGFUSE_BLOB_STORAGE_GCS_ALLOWED_BUCKETS ?? [];+ if (!allowed.includes(bucketName.toLowerCase().trim())) {+ throw new GcsBucketNotAllowedError(+ "gcs-bucket-not-allowed",+ allowed.length === 0+ ? "Google Cloud Storage exports with default credentials are disabled. Set LANGFUSE_BLOB_STORAGE_GCS_ALLOWED_BUCKETS to enable them, or provide a service account key."+ : `Bucket "${bucketName}" is not in LANGFUSE_BLOB_STORAGE_GCS_ALLOWED_BUCKETS. Use an allowed bucket or provide a service account key.`,+ );+ }+}+export function blobStorageEndpointConnectionValidationOptions(whitelist: OutboundUrlValidationWhitelist = blobStorageEndpointWhitelistFromEnv(),): OutboundUrlConnectionValidationOptions | undefined {diff --git a/web/public/generated/api/openapi.yml b/web/public/generated/api/openapi.ymlindex 5197065c54..5b08f9b3f7 100644--- a/web/public/generated/api/openapi.yml+++ b/web/public/generated/api/openapi.yml@@ -9335,6 +9335,7 @@ components:- S3- S3_COMPATIBLE- AZURE_BLOB_STORAGE+ - GOOGLE_CLOUD_STORAGEBlobStorageIntegrationFileType:title: BlobStorageIntegrationFileTypetype: string@@ -9443,11 +9444,15 @@ components:Name of the storage bucket. For AZURE_BLOB_STORAGE, must be a validAzure container name (3-63 chars, lowercase letters, numbers, andhyphens only, must start and end with a letter or number, no- consecutive hyphens).+ consecutive hyphens). For GOOGLE_CLOUD_STORAGE with default+ credentials, the bucket must be listed in+ `LANGFUSE_BLOB_STORAGE_GCS_ALLOWED_BUCKETS`.endpoint:type: stringnullable: true- description: Custom endpoint URL (required for S3_COMPATIBLE type)+ description: >-+ Custom endpoint URL (required for S3_COMPATIBLE type). Ignored for+ GOOGLE_CLOUD_STORAGE.region:type: stringdescription: >-@@ -9455,15 +9460,26 @@ components:R2, MinIO, Azure location IDs such as eastus, OCI). Leading andtrailing whitespace is removed. The remaining value must be 1-63letters, numbers, or hyphens, and cannot start or end with a hyphen.- Examples: us-east-1, europe-west1, eastus, auto.+ Examples: us-east-1, europe-west1, eastus, auto. Not used by+ GOOGLE_CLOUD_STORAGE; pass auto.accessKeyId:type: stringnullable: true- description: Access key ID for authentication+ description: Access key ID for authentication. Not used for GOOGLE_CLOUD_STORAGE.secretAccessKey:type: stringnullable: true- description: Secret access key for authentication (will be encrypted when stored)+ description: >-+ Secret access key for authentication (will be encrypted when+ stored). When omitted on update, the stored secret is kept, unless+ the type changes between GOOGLE_CLOUD_STORAGE and another type.+++ For GOOGLE_CLOUD_STORAGE, a GCP service account JSON key. On+ self-hosted deployments, pass `__GCS_DEFAULT_CREDENTIALS__` instead+ to use the deployment's Application Default Credentials; the bucket+ must then be listed in `LANGFUSE_BLOB_STORAGE_GCS_ALLOWED_BUCKETS`.+ Default credentials are not available on Langfuse Cloud.prefix:type: stringnullable: truediff --git a/web/src/__tests__/server/blob-storage-integration-trpc.servertest.ts b/web/src/__tests__/server/blob-storage-integration-trpc.servertest.tsindex c7b6eb3fe0..dc6996d065 100644--- a/web/src/__tests__/server/blob-storage-integration-trpc.servertest.ts+++ b/web/src/__tests__/server/blob-storage-integration-trpc.servertest.ts@@ -4,7 +4,7 @@ import type { Session } from "next-auth";import { appRouter } from "@/src/server/api/root";import { createInnerTRPCContext } from "@/src/server/api/trpc";-import { encrypt } from "@langfuse/shared/encryption";+import { decrypt, encrypt } from "@langfuse/shared/encryption";import { prisma } from "@langfuse/shared/src/db";import {BlobStorageIntegrationProcessingQueue,@@ -16,6 +16,7 @@ import {OBSERVATION_FIELD_GROUPS_FULL,LEGACY_EXPORT_PROJECT_CUTOFF,LEGACY_BLOB_EXPORTER_CUTOFF,+ GCS_USE_DEFAULT_CREDENTIALS,type Plan,} from "@langfuse/shared";import { env } from "@/src/env.mjs";@@ -252,6 +253,376 @@ describe("Blob Storage Integration tRPC Router", () => {vi.clearAllMocks();});+ describe("GOOGLE_CLOUD_STORAGE", () => {+ const original = {+ buckets: sharedEnv.LANGFUSE_BLOB_STORAGE_GCS_ALLOWED_BUCKETS,+ region: sharedEnv.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION,+ };+ // Schema-valid but fake: never sent to Google (StorageServiceFactory is mocked).+ const fakeServiceAccountKey = JSON.stringify({+ type: "service_account",+ project_id: "test-project",+ private_key_id: "kid",+ private_key:+ "-----BEGIN PRIVATE KEY-----\nfake\n-----END PRIVATE KEY-----\n",+ client_email: "[email protected]",+ client_id: "1",+ auth_uri: "https://accounts.google.com/o/oauth2/auth",+ token_uri: "https://oauth2.googleapis.com/token",+ auth_provider_x509_cert_url: "https://www.googleapis.com/oauth2/v1/certs",+ client_x509_cert_url:+ "https://www.googleapis.com/robot/v1/metadata/x509/x",+ });+ const gcsAdcConfig = {+ ...baseConfig,+ type: "GOOGLE_CLOUD_STORAGE" as const,+ bucketName: "allowed-bucket",+ accessKeyId: "ignored-key",+ secretAccessKey: GCS_USE_DEFAULT_CREDENTIALS,+ };+ const gcsKeyConfig = {+ ...gcsAdcConfig,+ bucketName: "customer-bucket",+ secretAccessKey: fakeServiceAccountKey,+ };+ const findIntegration = (projectId: string) =>+ prisma.blobStorageIntegration.findUnique({ where: { projectId } });++ beforeEach(() => {+ sharedEnv.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = undefined;+ sharedEnv.LANGFUSE_BLOB_STORAGE_GCS_ALLOWED_BUCKETS = ["allowed-bucket"];+ });++ afterEach(() => {+ sharedEnv.LANGFUSE_BLOB_STORAGE_GCS_ALLOWED_BUCKETS = original.buckets;+ sharedEnv.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = original.region;+ });++ describe("default credentials (ADC)", () => {+ it("saves an allowlisted bucket without storing any keys", async () => {+ const { caller, project } = await prepare({+ plan: "self-hosted:enterprise",+ });++ await caller.blobStorageIntegration.update({+ projectId: project.id,+ ...gcsAdcConfig,+ });++ expect(await findIntegration(project.id)).toMatchObject({+ type: "GOOGLE_CLOUD_STORAGE",+ bucketName: "allowed-bucket",+ accessKeyId: null,+ secretAccessKey: null,+ });+ });++ it("rejects a bucket outside LANGFUSE_BLOB_STORAGE_GCS_ALLOWED_BUCKETS", async () => {+ const { caller, project } = await prepare({+ plan: "self-hosted:enterprise",+ });++ await expect(+ caller.blobStorageIntegration.update({+ projectId: project.id,+ ...gcsAdcConfig,+ bucketName: "someone-elses-bucket",+ }),+ ).rejects.toThrow(/LANGFUSE_BLOB_STORAGE_GCS_ALLOWED_BUCKETS/);+ });++ it("clears stored S3 keys when an integration switches to GCS", async () => {+ const { caller, project } = await prepare({+ plan: "self-hosted:enterprise",+ });+ await createIntegration({ projectId: project.id });++ await caller.blobStorageIntegration.update({+ projectId: project.id,+ ...gcsAdcConfig,+ });++ const integration = await findIntegration(project.id);+ expect(integration?.accessKeyId).toBeNull();+ expect(integration?.secretAccessKey).toBeNull();+ });++ it("does not store an endpoint left over from another provider", async () => {+ const { caller, project } = await prepare({+ plan: "self-hosted:enterprise",+ });++ // The form keeps the hidden endpoint value across a provider switch.+ await caller.blobStorageIntegration.update({+ projectId: project.id,+ ...gcsAdcConfig,+ endpoint: "http://minio.internal:9000",+ });++ expect((await findIntegration(project.id))?.endpoint).toBeNull();+ });++ it("treats switching from S3 with no new secret as keyless (allowlist applies)", async () => {+ const { caller, project } = await prepare({+ plan: "self-hosted:enterprise",+ });+ await createIntegration({ projectId: project.id });++ // The stored S3 secret must not be reused as a GCS key.+ await expect(+ caller.blobStorageIntegration.update({+ projectId: project.id,+ ...gcsAdcConfig,+ bucketName: "someone-elses-bucket",+ secretAccessKey: null,+ }),+ ).rejects.toThrow(/LANGFUSE_BLOB_STORAGE_GCS_ALLOWED_BUCKETS/);+ });++ it("does not save the sentinel as a secret after switching to Azure", async () => {+ const { caller, project } = await prepare({+ plan: "self-hosted:enterprise",+ });+ await caller.blobStorageIntegration.update({+ projectId: project.id,+ ...gcsAdcConfig,+ });++ // The form keeps the sentinel in the secret field across a provider switch.+ await expect(+ caller.blobStorageIntegration.update({+ projectId: project.id,+ ...baseConfig,+ type: "AZURE_BLOB_STORAGE",+ secretAccessKey: GCS_USE_DEFAULT_CREDENTIALS,+ }),+ ).rejects.toThrow(/Secret access key is required/);+ expect((await findIntegration(project.id))?.type).toBe(+ "GOOGLE_CLOUD_STORAGE",+ );+ });++ it("validates with a plain upload (no signed URL)", async () => {+ const uploadFile = vi.fn().mockResolvedValue(undefined);+ const uploadWithSignedUrl = vi.fn();+ (StorageServiceFactory.getInstance as Mock).mockReturnValue({+ uploadFile,+ uploadWithSignedUrl,+ });+ const { caller, project } = await prepare({+ plan: "self-hosted:enterprise",+ });+ await caller.blobStorageIntegration.update({+ projectId: project.id,+ ...gcsAdcConfig,+ });++ const result = await caller.blobStorageIntegration.validate({+ projectId: project.id,+ });++ expect(result.success).toBe(true);+ expect(StorageServiceFactory.getInstance).toHaveBeenLastCalledWith(+ expect.objectContaining({+ useGoogleCloudStorage: true,+ bucketName: "allowed-bucket",+ googleCloudCredentials: undefined,+ accessKeyId: undefined,+ secretAccessKey: undefined,+ }),+ );+ expect(uploadFile).toHaveBeenCalledWith(+ expect.objectContaining({ fileName: result.testFileName }),+ );+ expect(uploadWithSignedUrl).not.toHaveBeenCalled();+ });++ it("is unavailable on Langfuse Cloud", async () => {+ sharedEnv.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = "US";+ const { caller, project } = await prepare({ plan: "cloud:team" });++ await expect(+ caller.blobStorageIntegration.update({+ projectId: project.id,+ ...gcsAdcConfig,+ }),+ ).rejects.toThrow(/self-hosted/);+ });+ });++ describe("service account key", () => {+ it("stores the key encrypted and needs no allowlist", async () => {+ const { caller, project } = await prepare({+ plan: "self-hosted:enterprise",+ });++ await caller.blobStorageIntegration.update({+ projectId: project.id,+ ...gcsKeyConfig,+ });++ const integration = await findIntegration(project.id);+ expect(integration?.bucketName).toBe("customer-bucket");+ expect(integration?.accessKeyId).toBeNull();+ expect(integration?.secretAccessKey).toBeTruthy();+ expect(integration?.secretAccessKey).not.toContain("service_account");+ expect(decrypt(integration!.secretAccessKey!)).toBe(+ fakeServiceAccountKey,+ );+ });++ it("rejects a secret that is not a service account JSON key", async () => {+ const { caller, project } = await prepare({+ plan: "self-hosted:enterprise",+ });++ await expect(+ caller.blobStorageIntegration.update({+ projectId: project.id,+ ...gcsKeyConfig,+ secretAccessKey: "/etc/passwd",+ }),+ ).rejects.toThrow(/service account JSON key/);+ });++ it("keeps the stored key when an update omits the secret", async () => {+ const { caller, project } = await prepare({+ plan: "self-hosted:enterprise",+ });+ await caller.blobStorageIntegration.update({+ projectId: project.id,+ ...gcsKeyConfig,+ });++ await caller.blobStorageIntegration.update({+ projectId: project.id,+ ...gcsKeyConfig,+ secretAccessKey: null,+ prefix: "renamed/",+ });++ const integration = await findIntegration(project.id);+ expect(integration?.prefix).toBe("renamed/");+ expect(decrypt(integration!.secretAccessKey!)).toBe(+ fakeServiceAccountKey,+ );+ });++ it("drops the stored key when switched to default credentials", async () => {+ const { caller, project } = await prepare({+ plan: "self-hosted:enterprise",+ });+ await caller.blobStorageIntegration.update({+ projectId: project.id,+ ...gcsKeyConfig,+ });++ await caller.blobStorageIntegration.update({+ projectId: project.id,+ ...gcsAdcConfig,+ });++ expect((await findIntegration(project.id))?.secretAccessKey).toBeNull();+ });++ it("validates with the key and a signed URL", async () => {+ const uploadWithSignedUrl = vi+ .fn()+ .mockResolvedValue({ signedUrl: "https://signed.example/gcs" });+ (StorageServiceFactory.getInstance as Mock).mockReturnValue({+ uploadWithSignedUrl,+ });+ const { caller, project } = await prepare({+ plan: "self-hosted:enterprise",+ });+ await caller.blobStorageIntegration.update({+ projectId: project.id,+ ...gcsKeyConfig,+ });++ const result = await caller.blobStorageIntegration.validate({+ projectId: project.id,+ });++ expect(result.success).toBe(true);+ expect(StorageServiceFactory.getInstance).toHaveBeenLastCalledWith(+ expect.objectContaining({+ useGoogleCloudStorage: true,+ bucketName: "customer-bucket",+ googleCloudCredentials: fakeServiceAccountKey,+ secretAccessKey: undefined,+ }),+ );+ expect(uploadWithSignedUrl).toHaveBeenCalled();+ });++ it("works on Langfuse Cloud", async () => {+ sharedEnv.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = "US";+ const { caller, project } = await prepare({ plan: "cloud:team" });++ await caller.blobStorageIntegration.update({+ projectId: project.id,+ ...gcsKeyConfig,+ });++ expect((await findIntegration(project.id))?.type).toBe(+ "GOOGLE_CLOUD_STORAGE",+ );+ });++ it("never reuses a stored GCS key as an S3/Azure secret", async () => {+ const { caller, project } = await prepare({+ plan: "self-hosted:enterprise",+ });+ await caller.blobStorageIntegration.update({+ projectId: project.id,+ ...gcsKeyConfig,+ });++ await expect(+ caller.blobStorageIntegration.update({+ projectId: project.id,+ ...baseConfig,+ type: "AZURE_BLOB_STORAGE",+ secretAccessKey: null,+ }),+ ).rejects.toThrow(/Secret access key is required/);+ });++ it("reports hasSecretAccessKey without exposing the key", async () => {+ const { caller, project } = await prepare({+ plan: "self-hosted:enterprise",+ });+ await caller.blobStorageIntegration.update({+ projectId: project.id,+ ...gcsKeyConfig,+ });++ const { config } = await caller.blobStorageIntegration.get({+ projectId: project.id,+ });+ expect(config?.hasSecretAccessKey).toBe(true);+ expect(config).not.toHaveProperty("secretAccessKey");+ });+ });+ });++ describe("stored secret reuse", () => {+ it("never reuses a stored S3 secret as an Azure key", async () => {+ const { caller, project } = await prepare();+ await createIntegration({ projectId: project.id });++ await expect(+ caller.blobStorageIntegration.update({+ projectId: project.id,+ ...baseConfig,+ type: "AZURE_BLOB_STORAGE",+ secretAccessKey: null,+ }),+ ).rejects.toThrow(/Secret access key is required/);+ });+ });+describe("region normalization", () => {it("persists a trimmed region", async () => {const { caller, project } = await prepare();diff --git a/web/src/features/blobstorage-integration/BlobStorageIntegrationPage.tsx b/web/src/features/blobstorage-integration/BlobStorageIntegrationPage.tsxindex b485d33942..a84ff38fc0 100644--- a/web/src/features/blobstorage-integration/BlobStorageIntegrationPage.tsx+++ b/web/src/features/blobstorage-integration/BlobStorageIntegrationPage.tsx@@ -92,11 +92,11 @@ export default function BlobStorageIntegrationPage() {><p className="text-primary mb-4 text-sm">Configure scheduled exports of your trace data to Amazon S3,- S3-compatible storages, or Azure Blob Storage. Set up a hourly, daily,- or weekly export to your own storage for data analysis or backup- purposes. Use the "Validate" button to test your configuration- by uploading a small test file, and the "Run Now" button to- trigger an immediate export.+ S3-compatible storages, Azure Blob Storage, or Google Cloud Storage. Set+ up a hourly, daily, or weekly export to your own storage for data+ analysis or backup purposes. Use the "Validate" button to test+ your configuration by uploading a small test file, and the "Run+ Now" button to trigger an immediate export.</p>{!hasEntitlement ? (<p className="text-sm">diff --git a/web/src/features/blobstorage-integration/blobstorage-integration-router.ts b/web/src/features/blobstorage-integration/blobstorage-integration-router.tsindex c6f587caa0..8747ee68a3 100644--- a/web/src/features/blobstorage-integration/blobstorage-integration-router.ts+++ b/web/src/features/blobstorage-integration/blobstorage-integration-router.ts@@ -24,6 +24,7 @@ import {StorageServiceFactory,blobStorageEndpointConnectionValidationOptions,validateBlobStorageEndpoint,+ assertGcsBlobStorageBucketAllowed,} from "@langfuse/shared/src/server";import { randomUUID } from "crypto";import { decrypt } from "@langfuse/shared/encryption";@@ -98,17 +99,21 @@ export const blobStorageIntegrationRouter = createTRPCRouter({projectId: input.projectId,});try {- const config = await ctx.prisma.blobStorageIntegration.findFirst({+ const row = await ctx.prisma.blobStorageIntegration.findFirst({where: {projectId: input.projectId,},- omit: {- secretAccessKey: true,- },});+ // Never return the (encrypted) secret; only whether one is stored, so the+ // form can tell a keyless GCS integration from one with a key.+ let config = null;+ if (row) {+ const { secretAccessKey, ...rest } = row;+ config = { ...rest, hasSecretAccessKey: Boolean(secretAccessKey) };+ }return {- config: config ?? null,+ config,writeMode: env.LANGFUSE_MIGRATION_V4_WRITE_MODE,};} catch (e) {@@ -389,19 +394,26 @@ export const blobStorageIntegrationRouter = createTRPCRouter({if (endpoint) {await validateBlobStorageEndpoint(endpoint);}+ const isGcs = type === BlobStorageIntegrationType.GOOGLE_CLOUD_STORAGE;+ // GCS: stored secret = customer service account JSON key; none = the+ // deployment's default credentials, which only allowlisted buckets get.+ const gcsServiceAccountKey = isGcs ? secretAccessKey : undefined;+ if (isGcs && !gcsServiceAccountKey) {+ assertGcsBlobStorageBucketAllowed(bucketName);+ }// Create storage service with provided configurationconst storageService = StorageServiceFactory.getInstance({- accessKeyId: accessKeyId || undefined,- secretAccessKey,+ accessKeyId: isGcs ? undefined : accessKeyId || undefined,+ secretAccessKey: isGcs ? undefined : secretAccessKey,bucketName,endpoint: endpoint || undefined,region: region || undefined,forcePathStyle: forcePathStyle || false,useAzureBlob: type === BlobStorageIntegrationType.AZURE_BLOB_STORAGE,- useGoogleCloudStorage: false, // Not supported in blob storage integration+ useGoogleCloudStorage: isGcs,useOCIObjectStorage: false, // Not supported in blob storage integration- googleCloudCredentials: undefined,+ googleCloudCredentials: gcsServiceAccountKey,awsSse: undefined,awsSseKmsKeyId: undefined,externalEndpoint: undefined,@@ -418,13 +430,23 @@ Timestamp: ${new Date().toISOString()}Configuration: ${type} storageThis file can be safely deleted.`;- // Upload the test file- const result = await storageService.uploadWithSignedUrl({+ // Upload the test file. Keyless GCS skips the signed URL: V4 signing+ // needs a private key, which ADC identities (e.g. GKE metadata) don't+ // have, and the export itself never signs. A GCS key can sign.+ const testFile = {fileName: testFileName,fileType: "text/plain",data: testContent,- expiresInSeconds: 3600, // 1 hour- });+ };+ let signedUrl: string | undefined;+ if (isGcs && !gcsServiceAccountKey) {+ await storageService.uploadFile(testFile);+ } else {+ ({ signedUrl } = await storageService.uploadWithSignedUrl({+ ...testFile,+ expiresInSeconds: 3600, // 1 hour+ }));+ }logger.info(`Blob storage validation successful for project ${input.projectId}`,@@ -450,7 +472,7 @@ This file can be safely deleted.`;success: true,message: "Validation successful! Test file uploaded.",testFileName,- signedUrl: result.signedUrl,+ signedUrl,};} catch (e) {const errorMessage = getErrorMessage(diff --git a/web/src/features/blobstorage-integration/components/BlobStorageIntegrationContainer.tsx b/web/src/features/blobstorage-integration/components/BlobStorageIntegrationContainer.tsxindex e60b007ef0..259cf2a0f3 100644--- a/web/src/features/blobstorage-integration/components/BlobStorageIntegrationContainer.tsx+++ b/web/src/features/blobstorage-integration/components/BlobStorageIntegrationContainer.tsx@@ -30,7 +30,9 @@ export const BlobStorageIntegrationContainer = ({projectId,writeMode,}: {- config: Partial<BlobStorageIntegration> | null;+ config:+ | (Partial<BlobStorageIntegration> & { hasSecretAccessKey?: boolean })+ | null;projectId: string;writeMode: V4WriteMode;}) => {diff --git a/web/src/features/blobstorage-integration/components/BlobStorageIntegrationForm.clienttest.tsx b/web/src/features/blobstorage-integration/components/BlobStorageIntegrationForm.clienttest.tsxindex 283397d40f..049793b2c4 100644--- a/web/src/features/blobstorage-integration/components/BlobStorageIntegrationForm.clienttest.tsx+++ b/web/src/features/blobstorage-integration/components/BlobStorageIntegrationForm.clienttest.tsx@@ -159,6 +159,26 @@ describe("BlobStorageIntegrationForm draft lifetime (keyed remount)", () => {expect(bucketInput()).toHaveValue("mid-save-typing");});+ it("switching from GCS to S3 drops a typed GCS service account key", async () => {+ render(+ ui(+ "p1:new",+ buildBlobStorageFormValues(+ { type: BlobStorageIntegrationType.GOOGLE_CLOUD_STORAGE },+ exportSourceCtx,+ ),+ ),+ );+ fireEvent.change(screen.getByLabelText("GCP Service Account Key (JSON)"), {+ target: { value: '{"type":"service_account"}' },+ });++ fireEvent.click(screen.getByRole("combobox", { name: "Storage Provider" }));+ fireEvent.click(await screen.findByRole("option", { name: "Amazon S3" }));++ expect(await screen.findByLabelText(/Secret Access Key/)).toHaveValue("");+ });+it("submit passes the draft values through unchanged", async () => {const onSubmit = vi.fn();render(diff --git a/web/src/features/blobstorage-integration/components/BlobStorageIntegrationForm.tsx b/web/src/features/blobstorage-integration/components/BlobStorageIntegrationForm.tsxindex 8c5d1cd785..159eb59219 100644--- a/web/src/features/blobstorage-integration/components/BlobStorageIntegrationForm.tsx+++ b/web/src/features/blobstorage-integration/components/BlobStorageIntegrationForm.tsx@@ -99,7 +99,10 @@ export const BlobStorageIntegrationForm = ({return (<Form {...blobStorageForm}><form className="space-y-3" onSubmit={submit}>- <StorageProviderFields control={control} />+ <StorageProviderFields+ control={control}+ setValue={blobStorageForm.setValue}+ /><ExportScheduleFields control={control} /><ExportSourceFieldcontrol={control}diff --git a/web/src/features/blobstorage-integration/components/StorageProviderFields.tsx b/web/src/features/blobstorage-integration/components/StorageProviderFields.tsxindex 6423695508..3c63cf240b 100644--- a/web/src/features/blobstorage-integration/components/StorageProviderFields.tsx+++ b/web/src/features/blobstorage-integration/components/StorageProviderFields.tsx@@ -1,5 +1,5 @@/* eslint-disable no-nested-ternary */-import { useWatch } from "react-hook-form";+import { type UseFormSetValue, useWatch } from "react-hook-form";import {FormControl,FormDescription,@@ -12,23 +12,35 @@ import { Input } from "@/src/components/ui/input";import { PasswordInput } from "@/src/components/design-system/PasswordInput/PasswordInput";import { SelectInput } from "@/src/components/design-system/SelectInput/SelectInput";import { Switch } from "@/src/components/design-system/Switch/Switch";-import { BlobStorageIntegrationType } from "@langfuse/shared";+import {+ BlobStorageIntegrationType,+ GCS_USE_DEFAULT_CREDENTIALS,+} from "@langfuse/shared";import { useLangfuseCloudRegion } from "@/src/features/organizations";-import { type BlobStorageFormControl } from "@/src/features/blobstorage-integration/components/formValues";+import {+ type BlobStorageFormControl,+ type BlobStorageFormValues,+} from "@/src/features/blobstorage-integration/components/formValues";// Provider selection plus the connection fields whose labels and visibility// depend on it: bucket/container, endpoint, region, path style, credentials,// and prefix.export const StorageProviderFields = ({control,+ setValue,}: {control: BlobStorageFormControl;+ setValue: UseFormSetValue<BlobStorageFormValues>;}) => {const { isLangfuseCloud } = useLangfuseCloudRegion();// Check if this is a self-hosted instance (no cloud region set)const isSelfHosted = !isLangfuseCloud;const integrationType =useWatch({ control, name: "type" }) ?? BlobStorageIntegrationType.S3;+ const isGcs = integrationType === "GOOGLE_CLOUD_STORAGE";+ const secretAccessKey = useWatch({ control, name: "secretAccessKey" });+ const isGcsDefaultCredentials =+ isGcs && secretAccessKey === GCS_USE_DEFAULT_CREDENTIALS;return (<>@@ -41,7 +53,14 @@ export const StorageProviderFields = ({<FormControl><SelectInputvalue={field.value}- onValueChange={field.onChange}+ onValueChange={(value) => {+ // A GCS key (or the ADC sentinel) is not an S3/Azure secret,+ // and vice versa.+ if ((value === "GOOGLE_CLOUD_STORAGE") !== isGcs) {+ setValue("secretAccessKey", "", { shouldDirty: true });+ }+ field.onChange(value);+ }}placeholder="Select provider"options={[{ value: BlobStorageIntegrationType.S3, label: "Amazon S3" },@@ -53,6 +72,10 @@ export const StorageProviderFields = ({value: BlobStorageIntegrationType.AZURE_BLOB_STORAGE,label: "Azure Blob Storage",},+ {+ value: BlobStorageIntegrationType.GOOGLE_CLOUD_STORAGE,+ label: "Google Cloud Storage",+ },]}/></FormControl>@@ -80,7 +103,11 @@ export const StorageProviderFields = ({<FormDescription>{integrationType === "AZURE_BLOB_STORAGE"? "Azure container name (3-63 chars, lowercase letters, numbers, and hyphens only)"- : "The S3 bucket name"}+ : isGcsDefaultCredentials+ ? "GCS bucket name. With default credentials it must be listed in LANGFUSE_BLOB_STORAGE_GCS_ALLOWED_BUCKETS"+ : isGcs+ ? "GCS bucket name"+ : "The S3 bucket name"}</FormDescription><FormMessage /></FormItem>@@ -88,7 +115,7 @@ export const StorageProviderFields = ({/>{/* Endpoint URL field - Only shown for S3-compatible and Azure */}- {integrationType !== "S3" && (+ {integrationType !== "S3" && !isGcs && (<FormFieldcontrol={control}name="endpoint"@@ -110,7 +137,7 @@ export const StorageProviderFields = ({)}{/* Region field - Only shown for Amazon S3 or compatible storage */}- {integrationType !== "AZURE_BLOB_STORAGE" && (+ {integrationType !== "AZURE_BLOB_STORAGE" && !isGcs && (<FormFieldcontrol={control}name="region"@@ -156,75 +183,136 @@ export const StorageProviderFields = ({/>)}- <FormField- control={control}- name="accessKeyId"- render={({ field }) => (- <FormItem>- <FormLabel>- {integrationType === "AZURE_BLOB_STORAGE"- ? "Storage Account Name"- : integrationType === "S3"- ? "AWS Access Key ID"- : "Access Key ID"}- {/* Show optional indicator for S3 types on self-hosted instances with entitlement */}- {isSelfHosted && integrationType === "S3" && (- <span className="text-muted-foreground"> (optional)</span>- )}- </FormLabel>- <FormControl>- <Input {...field} />- </FormControl>- <FormDescription>- {integrationType === "AZURE_BLOB_STORAGE"- ? "Your Azure storage account name"- : integrationType === "S3"- ? isSelfHosted- ? "Your AWS IAM user access key ID. Leave empty to use host credentials (IAM roles, instance profiles, etc.)"- : "Your AWS IAM user access key ID"- : "Access key for your S3-compatible storage"}- </FormDescription>- <FormMessage />- </FormItem>- )}- />+ {/* GCS credentials: service account JSON key, or (self-hosted) default+ credentials, mirroring the Vertex AI LLM connection form. */}+ {isGcs && isSelfHosted && (+ <FormField+ control={control}+ name="secretAccessKey"+ render={({ field }) => (+ <FormItem>+ <span className="flex">+ <span className="flex-1">+ <FormLabel>+ Use Application Default Credentials (ADC)+ </FormLabel>+ <FormDescription>+ Write as this deployment's own GCP identity instead of+ a service account key. The bucket must be listed in+ LANGFUSE_BLOB_STORAGE_GCS_ALLOWED_BUCKETS.+ </FormDescription>+ </span>+ <FormControl>+ <Switch+ checked={field.value === GCS_USE_DEFAULT_CREDENTIALS}+ onCheckedChange={(checked) =>+ field.onChange(checked ? GCS_USE_DEFAULT_CREDENTIALS : "")+ }+ />+ </FormControl>+ </span>+ </FormItem>+ )}+ />+ )}+ {isGcs && !isGcsDefaultCredentials && (+ <FormField+ control={control}+ name="secretAccessKey"+ render={({ field }) => (+ <FormItem>+ <FormLabel>GCP Service Account Key (JSON)</FormLabel>+ <FormControl>+ <PasswordInput+ placeholder='{"type": "service_account", ...}'+ {...field}+ value={field.value || ""}+ />+ </FormControl>+ <FormDescription>+ Stored encrypted. Leave empty to keep the saved key. The key+ needs write access to the bucket.+ </FormDescription>+ <FormMessage />+ </FormItem>+ )}+ />+ )}- <FormField- control={control}- name="secretAccessKey"- render={({ field }) => (- <FormItem>- <FormLabel>- {integrationType === "AZURE_BLOB_STORAGE"- ? "Storage Account Key"- : integrationType === "S3"- ? "AWS Secret Access Key"- : "Secret Access Key"}- {/* Show optional indicator for S3 types on self-hosted instances with entitlement */}- {isSelfHosted && integrationType === "S3" && (- <span className="text-muted-foreground"> (optional)</span>- )}- </FormLabel>- <FormControl>- <PasswordInput- placeholder="********************"- {...field}- value={field.value || ""}- />- </FormControl>- <FormDescription>- {integrationType === "AZURE_BLOB_STORAGE"- ? "Your Azure storage account access key"- : integrationType === "S3"- ? isSelfHosted- ? "Your AWS IAM user secret access key. Leave empty to use host credentials (IAM roles, instance profiles, etc.)"- : "Your AWS IAM user secret access key"- : "Secret key for your S3-compatible storage"}- </FormDescription>- <FormMessage />- </FormItem>- )}- />+ {/* S3/Azure credentials */}+ {!isGcs && (+ <FormField+ control={control}+ name="accessKeyId"+ render={({ field }) => (+ <FormItem>+ <FormLabel>+ {integrationType === "AZURE_BLOB_STORAGE"+ ? "Storage Account Name"+ : integrationType === "S3"+ ? "AWS Access Key ID"+ : "Access Key ID"}+ {/* Show optional indicator for S3 types on self-hosted instances with entitlement */}+ {isSelfHosted && integrationType === "S3" && (+ <span className="text-muted-foreground"> (optional)</span>+ )}+ </FormLabel>+ <FormControl>+ <Input {...field} />+ </FormControl>+ <FormDescription>+ {integrationType === "AZURE_BLOB_STORAGE"+ ? "Your Azure storage account name"+ : integrationType === "S3"+ ? isSelfHosted+ ? "Your AWS IAM user access key ID. Leave empty to use host credentials (IAM roles, instance profiles, etc.)"+ : "Your AWS IAM user access key ID"+ : "Access key for your S3-compatible storage"}+ </FormDescription>+ <FormMessage />+ </FormItem>+ )}+ />+ )}++ {!isGcs && (+ <FormField+ control={control}+ name="secretAccessKey"+ render={({ field }) => (+ <FormItem>+ <FormLabel>+ {integrationType === "AZURE_BLOB_STORAGE"+ ? "Storage Account Key"+ : integrationType === "S3"+ ? "AWS Secret Access Key"+ : "Secret Access Key"}+ {/* Show optional indicator for S3 types on self-hosted instances with entitlement */}+ {isSelfHosted && integrationType === "S3" && (+ <span className="text-muted-foreground"> (optional)</span>+ )}+ </FormLabel>+ <FormControl>+ <PasswordInput+ placeholder="********************"+ {...field}+ value={field.value || ""}+ />+ </FormControl>+ <FormDescription>+ {integrationType === "AZURE_BLOB_STORAGE"+ ? "Your Azure storage account access key"+ : integrationType === "S3"+ ? isSelfHosted+ ? "Your AWS IAM user secret access key. Leave empty to use host credentials (IAM roles, instance profiles, etc.)"+ : "Your AWS IAM user secret access key"+ : "Secret key for your S3-compatible storage"}+ </FormDescription>+ <FormMessage />+ </FormItem>+ )}+ />+ )}<FormFieldcontrol={control}diff --git a/web/src/features/blobstorage-integration/components/formValues.ts b/web/src/features/blobstorage-integration/components/formValues.tsindex bd0c7611e0..7216195df8 100644--- a/web/src/features/blobstorage-integration/components/formValues.ts+++ b/web/src/features/blobstorage-integration/components/formValues.ts@@ -8,6 +8,7 @@ import {type BlobStorageIntegration,type ObservationFieldGroupFull,type ExportSourceContext,+ GCS_USE_DEFAULT_CREDENTIALS,} from "@langfuse/shared";import type {blobStorageIntegrationFormSchema,@@ -28,16 +29,25 @@ export type BlobStorageFormControl = Control<>;export function buildBlobStorageFormValues(- state: Partial<BlobStorageIntegration> | undefined,+ state:+ | (Partial<BlobStorageIntegration> & { hasSecretAccessKey?: boolean })+ | undefined,exportSourceCtx: ExportSourceContext,): BlobStorageFormValues {+ // A saved GCS integration with no stored key uses default credentials;+ // preselect that so re-saving does not demand a key.+ const isKeylessGcs =+ state?.type === BlobStorageIntegrationType.GOOGLE_CLOUD_STORAGE &&+ state.hasSecretAccessKey === false;return {type: state?.type || BlobStorageIntegrationType.S3,bucketName: state?.bucketName || "",endpoint: state?.endpoint || null,region: state?.region || "auto",accessKeyId: state?.accessKeyId || "",- secretAccessKey: state?.secretAccessKey || null,+ secretAccessKey: isKeylessGcs+ ? GCS_USE_DEFAULT_CREDENTIALS+ : state?.secretAccessKey || null,prefix: state?.prefix || "",exportFrequency: (state?.exportFrequency ||"daily") as BlobStorageFormValues["exportFrequency"],diff --git a/web/src/features/blobstorage-integration/service.ts b/web/src/features/blobstorage-integration/service.tsindex 900dd9fbb4..d7e1012a2f 100644--- a/web/src/features/blobstorage-integration/service.ts+++ b/web/src/features/blobstorage-integration/service.ts@@ -8,11 +8,16 @@ import {type ObservationFieldGroupFull,BLOB_STORAGE_REGION_INVALID_MESSAGE,normalizeBlobStorageRegion,+ GCPServiceAccountKeySchema,+ GCS_USE_DEFAULT_CREDENTIALS,} from "@langfuse/shared";import { assertPersistedExportSourceAllowed } from "@/src/features/analytics-integrations/server";import { encrypt } from "@langfuse/shared/encryption";import { env } from "@/src/env.mjs";-import { validateBlobStorageEndpoint } from "@langfuse/shared/src/server";+import {+ assertGcsBlobStorageBucketAllowed,+ validateBlobStorageEndpoint,+} from "@langfuse/shared/src/server";type UpsertBlobStorageIntegrationInput = {type: BlobStorageIntegrationType;@@ -35,6 +40,40 @@ type UpsertBlobStorageIntegrationInput = {compressed?: boolean;};+// Same shape check the Vertex AI LLM connection applies to its JSON key.+function assertValidGcsServiceAccountKey(secret: string): void {+ let parsed: unknown;+ try {+ parsed = JSON.parse(secret);+ } catch {+ throw new InvalidRequestError(+ "GCS credentials must be a GCP service account JSON key",+ );+ }+ if (!GCPServiceAccountKeySchema.safeParse(parsed).success) {+ throw new InvalidRequestError("Invalid GCP service account JSON key");+ }+}++// Which providers can read each other's stored secret. S3 and S3-compatible+// share the access key shape; an Azure account key and a GCS JSON key do not.+function secretFamily(type: BlobStorageIntegrationType) {+ switch (type) {+ case BlobStorageIntegrationType.S3:+ case BlobStorageIntegrationType.S3_COMPATIBLE:+ return "s3";+ case BlobStorageIntegrationType.AZURE_BLOB_STORAGE:+ return "azure";+ case BlobStorageIntegrationType.GOOGLE_CLOUD_STORAGE:+ return "gcs";+ default: {+ const _exhaustive: never = type;+ _exhaustive;+ return null;+ }+ }+}+function resolveExportStartDate(params: {exportMode: BlobStorageExportMode;exportStartDate: Date | null;@@ -67,11 +106,28 @@ export async function upsertBlobStorageIntegration(params: {const { prisma, projectId, data } = params;const isSelfHosted = !env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION;+ const isGcs = data.type === BlobStorageIntegrationType.GOOGLE_CLOUD_STORAGE;const canUseHostCredentials =isSelfHosted && data.type === BlobStorageIntegrationType.S3;- const accessKeyId = data.accessKeyId?.trim() || null;- const secretAccessKey = data.secretAccessKey?.trim() || null;+ // GCS, like the Vertex AI LLM connection, takes either a service account JSON+ // key (stored encrypted, in secretAccessKey) or the default-credentials+ // sentinel (ADC; self-hosted only, bucket must be allowlisted). An omitted+ // secret on UPDATE keeps whatever is stored. GCS never uses accessKeyId.+ // The sentinel is never a real secret: the form keeps it when the provider is+ // switched away from GCS, so treat it as "no secret" for every type.+ const rawSecret = data.secretAccessKey?.trim() || null;+ const isSentinel = rawSecret === GCS_USE_DEFAULT_CREDENTIALS;+ const isKeylessGcs = isGcs && isSentinel;+ const secretAccessKey = isSentinel ? null : rawSecret;+ if (isGcs && secretAccessKey) {+ assertValidGcsServiceAccountKey(secretAccessKey);+ }++ const accessKeyId = isGcs ? null : data.accessKeyId?.trim() || null;+ // The GCS client always talks to Google, so an endpoint (e.g. one the form+ // kept from another provider) is neither validated nor stored.+ const endpoint = isGcs ? null : data.endpoint;let region: string;try {region = normalizeBlobStorageRegion(data.region);@@ -79,9 +135,9 @@ export async function upsertBlobStorageIntegration(params: {throw new InvalidRequestError(BLOB_STORAGE_REGION_INVALID_MESSAGE);}- if (data.endpoint) {+ if (endpoint) {try {- await validateBlobStorageEndpoint(data.endpoint);+ await validateBlobStorageEndpoint(endpoint);} catch (error) {throw new InvalidRequestError(`Invalid blob storage endpoint: ${error instanceof Error ? error.message : "Endpoint validation failed"}`,@@ -89,7 +145,7 @@ export async function upsertBlobStorageIntegration(params: {}}- if (!canUseHostCredentials && !accessKeyId) {+ if (!isGcs && !canUseHostCredentials && !accessKeyId) {throw new InvalidRequestError("Access Key ID and Secret Access Key are required",);@@ -103,7 +159,7 @@ export async function upsertBlobStorageIntegration(params: {const writeData = {type: data.type,bucketName: data.bucketName,- endpoint: data.endpoint,+ endpoint,region,accessKeyId,prefix: data.prefix,@@ -121,7 +177,8 @@ export async function upsertBlobStorageIntegration(params: {return prisma.$transaction(async (tx) => {const existing = await tx.blobStorageIntegration.findUnique({where: { projectId },- // createdAt/exportSource feed the post-upsert backstop below.+ // createdAt/exportSource feed the post-upsert backstop below;+ // type/secretAccessKey decide whether an update keeps a stored secret.select: {enabled: true,exportMode: true,@@ -129,23 +186,62 @@ export async function upsertBlobStorageIntegration(params: {runStartedAt: true,createdAt: true,exportSource: true,+ type: true,+ secretAccessKey: true,},});- // Require secret key for new integrations (unless using host credentials)- if (!existing) {- const isUsingHostCredentials =- canUseHostCredentials && (!accessKeyId || !secretAccessKey);- if (!isUsingHostCredentials && !secretAccessKey) {+ // A stored secret is only reusable within the same credential family.+ const canKeepStoredSecret =+ !!existing?.secretAccessKey &&+ secretFamily(existing.type) === secretFamily(data.type);+ // A GCS integration that will run keyless: explicitly requested, or an+ // update that sends no secret and has no stored GCS key to keep. Keyless+ // runs as the deployment identity, so it is gated by the bucket allowlist.+ const willRunKeyless =+ isGcs && (isKeylessGcs || (!secretAccessKey && !canKeepStoredSecret));+ if (willRunKeyless) {+ try {+ assertGcsBlobStorageBucketAllowed(data.bucketName);+ } catch (error) {throw new InvalidRequestError(- "Secret access key is required for new configuration",+ error instanceof Error ? error.message : "GCS bucket not allowed",);}}+ // New GCS integrations must pick a mode explicitly.+ if (!existing && isGcs && !isKeylessGcs && !secretAccessKey) {+ throw new InvalidRequestError(+ "A GCP service account JSON key or default credentials is required",+ );+ }+ // S3/Azure need a secret (new, or a reusable stored one) unless using host+ // credentials.+ const isUsingHostCredentials =+ canUseHostCredentials && (!accessKeyId || !secretAccessKey);+ if (+ !isGcs &&+ !isUsingHostCredentials &&+ !secretAccessKey &&+ !canKeepStoredSecret+ ) {+ throw new InvalidRequestError("Secret access key is required");+ }+const modeChanged = existing && existing.exportMode !== data.exportMode;const justEnabled = data.enabled && !existing?.enabled;const encryptedSecret = secretAccessKey ? encrypt(secretAccessKey) : null;+ // Only overwrite secretAccessKey when a new value is provided, so partial+ // updates don't wipe the existing encrypted secret. Keyless GCS, or a switch+ // to another credential family, clears it, so a secret is never reused by+ // the wrong provider.+ let secretAccessKeyUpdate: { secretAccessKey: string | null } | object = {};+ if (encryptedSecret) {+ secretAccessKeyUpdate = { secretAccessKey: encryptedSecret };+ } else if (willRunKeyless || !canKeepStoredSecret) {+ secretAccessKeyUpdate = { secretAccessKey: null };+ }// The CREATE payload always carries a concrete source, resolved by the// caller through resolveExportSource. Applying it unconditionally (rather@@ -171,9 +267,7 @@ export async function upsertBlobStorageIntegration(params: {},update: {...writeData,- // Only overwrite secretAccessKey when a new value is provided,- // so partial updates don't wipe the existing encrypted secret.- ...(encryptedSecret ? { secretAccessKey: encryptedSecret } : {}),+ ...secretAccessKeyUpdate,// Schedule an immediate retry when saving an errored integration// so the scheduler picks it up via the nextSyncAt clause....(existing?.lastError && data.enabled && !modeChangeddiff --git a/web/src/features/projects/ProjectSettingsPage.tsx b/web/src/features/projects/ProjectSettingsPage.tsxindex 080f37b602..671fd82ad9 100644--- a/web/src/features/projects/ProjectSettingsPage.tsx+++ b/web/src/features/projects/ProjectSettingsPage.tsx@@ -475,8 +475,9 @@ const Integrations = (props: { projectId: string }) => {<span className="font-bold">Blob Storage</span><p className="text-primary mb-4 text-sm">Configure scheduled exports of your trace data to S3 compatible- storages or Azure Blob Storage. Set up a scheduled export to your- own storage for data analysis or backup purposes.+ storages, Azure Blob Storage, or Google Cloud Storage. Set up a+ scheduled export to your own storage for data analysis or backup+ purposes.</p><div className="flex items-center gap-2"><ActionButtondiff --git a/web/src/features/public-api/types/blob-storage-integrations.ts b/web/src/features/public-api/types/blob-storage-integrations.tsindex aae661946e..48c234165f 100644--- a/web/src/features/public-api/types/blob-storage-integrations.ts+++ b/web/src/features/public-api/types/blob-storage-integrations.ts@@ -19,6 +19,7 @@ const BlobStorageIntegrationType = z.enum(["S3","S3_COMPATIBLE","AZURE_BLOB_STORAGE",+ "GOOGLE_CLOUD_STORAGE",]);const BlobStorageIntegrationFileType = z.enum([diff --git a/worker/src/__tests__/blobStorageGcsExport.unit.test.ts b/worker/src/__tests__/blobStorageGcsExport.unit.test.tsnew file mode 100644index 0000000000..f7e0f04093--- /dev/null+++ b/worker/src/__tests__/blobStorageGcsExport.unit.test.ts@@ -0,0 +1,197 @@+import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";++// Every StorageServiceFactory.getInstance call, so we can assert the GCS+// export is built keyless against the GCS client. Hoisted for the module mock.+const factoryCalls = vi.hoisted(() => [] as any[]);+const uploadCalls = vi.hoisted(() => [] as any[]);++vi.mock("@langfuse/shared/src/db", () => ({+ prisma: {+ blobStorageIntegration: {+ findUnique: vi.fn(),+ update: vi.fn().mockResolvedValue({}),+ updateMany: vi.fn().mockResolvedValue({ count: 1 }),+ },+ project: { findUnique: vi.fn().mockResolvedValue({ name: "p" }) },+ },+}));++vi.mock("@langfuse/shared/src/server", async (importOriginal) => {+ const mod =+ await importOriginal<typeof import("@langfuse/shared/src/server")>();+ async function* empty(): AsyncGenerator<Record<string, unknown>> {+ // no rows+ }+ return {+ ...mod,+ StorageServiceFactory: {+ getInstance: (params: any) => {+ factoryCalls.push(params);+ return {+ uploadFileBuffered: vi.fn(async (p: any) => {+ uploadCalls.push(p);+ for await (const _chunk of p.data) void _chunk;+ return undefined;+ }),+ uploadFile: vi.fn(async () => undefined),+ };+ },+ },+ getTracesForBlobStorageExport: () => empty(),+ getObservationsForBlobStorageExport: () => empty(),+ getScoresForBlobStorageExport: () => empty(),+ getEventsForBlobStorageExport: () => empty(),+ createModelCache: () => ({ getModel: async () => null }),+ blobStorageEndpointConnectionValidationOptions: () => undefined,+ };+});++import { createRequire } from "node:module";+import { prisma } from "@langfuse/shared/src/db";+import { encrypt } from "@langfuse/shared/encryption";+import { handleBlobStorageIntegrationProjectJob } from "../features/blobstorage/handleBlobStorageIntegrationProjectJob";+import type { Job } from "bullmq";++// The compiled @langfuse/shared reads its env through Node's require cache, a+// different instance from an ESM import of "@langfuse/shared/src/env", so+// mutate the one the allowlist helper actually sees.+const sharedEnv = createRequire(import.meta.url)("@langfuse/shared/src/env")+ .env as {+ LANGFUSE_BLOB_STORAGE_GCS_ALLOWED_BUCKETS: string[];+ NEXT_PUBLIC_LANGFUSE_CLOUD_REGION: string | undefined;+};++const makeJob = (): Job<any> =>+ ({+ id: "job-1",+ attemptsMade: 0,+ data: { id: "payload-1", payload: { projectId: "project-1" } },+ }) as unknown as Job<any>;++const gcsRow = (bucketName: string, secretAccessKey: string | null = null) => ({+ projectId: "project-1",+ type: "GOOGLE_CLOUD_STORAGE",+ bucketName,+ prefix: "",+ accessKeyId: null,+ secretAccessKey,+ region: "auto",+ endpoint: null,+ forcePathStyle: false,+ enabled: true,+ exportFrequency: "daily",+ fileType: "CSV",+ exportMode: "FROM_CUSTOM_DATE",+ exportStartDate: new Date(Date.now() - 2 * 60 * 60 * 1000),+ exportSource: "TRACES_OBSERVATIONS",+ exportFieldGroups: ["core"],+ compressed: false,+ lastSyncAt: new Date(Date.now() - 2 * 60 * 60 * 1000),+ createdAt: new Date("2026-01-01T00:00:00Z"),+ exportTuning: null,+});++describe("handleBlobStorageIntegrationProjectJob — GOOGLE_CLOUD_STORAGE", () => {+ const original = {+ buckets: sharedEnv.LANGFUSE_BLOB_STORAGE_GCS_ALLOWED_BUCKETS,+ region: sharedEnv.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION,+ };++ beforeEach(() => {+ factoryCalls.length = 0;+ uploadCalls.length = 0;+ vi.clearAllMocks();+ sharedEnv.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = undefined;+ sharedEnv.LANGFUSE_BLOB_STORAGE_GCS_ALLOWED_BUCKETS = ["allowed-bucket"];+ (prisma.blobStorageIntegration.findUnique as any).mockResolvedValue(+ gcsRow("allowed-bucket"),+ );+ });++ afterEach(() => {+ sharedEnv.LANGFUSE_BLOB_STORAGE_GCS_ALLOWED_BUCKETS = original.buckets;+ sharedEnv.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = original.region;+ });++ it("exports through the keyless GCS client for an allowlisted bucket", async () => {+ await handleBlobStorageIntegrationProjectJob(makeJob());++ expect(factoryCalls).toHaveLength(1);+ expect(factoryCalls[0]).toMatchObject({+ bucketName: "allowed-bucket",+ useGoogleCloudStorage: true,+ useAzureBlob: false,+ accessKeyId: undefined,+ secretAccessKey: undefined,+ googleCloudCredentials: undefined,+ });+ expect(uploadCalls.length).toBeGreaterThan(0);+ });++ it("disables the export once the bucket is removed from the allowlist", async () => {+ sharedEnv.LANGFUSE_BLOB_STORAGE_GCS_ALLOWED_BUCKETS = ["some-other-bucket"];++ await handleBlobStorageIntegrationProjectJob(makeJob());++ // A config fault: nothing is written and the integration is disabled+ // rather than retried.+ expect(factoryCalls).toHaveLength(0);+ expect(uploadCalls).toHaveLength(0);+ expect(prisma.blobStorageIntegration.update).toHaveBeenCalledWith(+ expect.objectContaining({+ data: expect.objectContaining({+ lastError: expect.stringContaining(+ "LANGFUSE_BLOB_STORAGE_GCS_ALLOWED_BUCKETS",+ ),+ }),+ }),+ );+ expect(prisma.blobStorageIntegration.updateMany).toHaveBeenCalledWith({+ where: { projectId: "project-1", enabled: true },+ data: { enabled: false },+ });+ });++ it("exports with a stored service account key, bypassing the allowlist", async () => {+ const key = JSON.stringify({ type: "service_account", project_id: "p" });+ sharedEnv.LANGFUSE_BLOB_STORAGE_GCS_ALLOWED_BUCKETS = [];+ (prisma.blobStorageIntegration.findUnique as any).mockResolvedValue(+ gcsRow("customer-bucket", encrypt(key)),+ );++ await handleBlobStorageIntegrationProjectJob(makeJob());++ expect(factoryCalls).toHaveLength(1);+ expect(factoryCalls[0]).toMatchObject({+ bucketName: "customer-bucket",+ useGoogleCloudStorage: true,+ googleCloudCredentials: key,+ accessKeyId: undefined,+ secretAccessKey: undefined,+ });+ expect(uploadCalls.length).toBeGreaterThan(0);+ });++ it("never reads a non-JSON stored secret as a key file path", async () => {+ (prisma.blobStorageIntegration.findUnique as any).mockResolvedValue(+ gcsRow("customer-bucket", encrypt("/var/run/secrets/key.json")),+ );++ await handleBlobStorageIntegrationProjectJob(makeJob());++ // A credential fault: disabled rather than retried.+ expect(factoryCalls).toHaveLength(0);+ expect(uploadCalls).toHaveLength(0);+ expect(prisma.blobStorageIntegration.update).toHaveBeenCalledWith(+ expect.objectContaining({+ data: expect.objectContaining({+ lastError: expect.stringContaining("service account JSON key"),+ }),+ }),+ );+ expect(prisma.blobStorageIntegration.updateMany).toHaveBeenCalledWith({+ where: { projectId: "project-1", enabled: true },+ data: { enabled: false },+ });+ });+});diff --git a/worker/src/features/blobstorage/handleBlobStorageIntegrationProjectJob.ts b/worker/src/features/blobstorage/handleBlobStorageIntegrationProjectJob.tsindex de64599b25..930e7723f9 100644--- a/worker/src/features/blobstorage/handleBlobStorageIntegrationProjectJob.ts+++ b/worker/src/features/blobstorage/handleBlobStorageIntegrationProjectJob.ts@@ -30,6 +30,7 @@ import {enrichObservationWithModelData,createModelCache,blobStorageEndpointConnectionValidationOptions,+ assertGcsBlobStorageBucketAllowed,validateBlobStorageEndpoint,dispatchProjectNotification,} from "@langfuse/shared/src/server";@@ -360,10 +361,31 @@ type BlobStorageConnectionConfig = {const createBlobStorageService = (config: BlobStorageConnectionConfig,-): StorageService =>- StorageServiceFactory.getInstance({- accessKeyId: config.accessKeyId,- secretAccessKey: config.secretAccessKey,+): StorageService => {+ const useGoogleCloudStorage =+ config.type === BlobStorageIntegrationType.GOOGLE_CLOUD_STORAGE;+ // GCS: a stored secret is the customer's service account JSON key; none means+ // default credentials (the deployment identity).+ const gcsServiceAccountKey = useGoogleCloudStorage+ ? config.secretAccessKey+ : undefined;+ if (useGoogleCloudStorage && !gcsServiceAccountKey) {+ // Re-checked per run so removing a bucket from the allowlist stops keyless+ // exports that were saved while it was allowed.+ assertGcsBlobStorageBucketAllowed(config.bucketName);+ }+ // The GCS client treats a non-JSON string as a key *file path*; a customer+ // secret must never be read as one.+ if (gcsServiceAccountKey && !gcsServiceAccountKey.trim().startsWith("{")) {+ // Named so classifyCustomerFault disables the integration instead of retrying.+ throw Object.assign(+ new Error("GCS credentials must be a service account JSON key"),+ { name: "InvalidGcsServiceAccountKey" },+ );+ }+ return StorageServiceFactory.getInstance({+ accessKeyId: useGoogleCloudStorage ? undefined : config.accessKeyId,+ secretAccessKey: useGoogleCloudStorage ? undefined : config.secretAccessKey,bucketName: config.bucketName,endpoint: config.endpoint ?? undefined,region: config.region,@@ -371,10 +393,13 @@ const createBlobStorageService = (awsSse: undefined,awsSseKmsKeyId: undefined,useAzureBlob: config.type === BlobStorageIntegrationType.AZURE_BLOB_STORAGE,- useGoogleCloudStorage: false, // Not supported in blob storage integration+ // Undefined → ADC (the deployment's own identity), allowlist-gated above.+ useGoogleCloudStorage,+ googleCloudCredentials: gcsServiceAccountKey,useOCIObjectStorage: false, // Not supported in blob storage integrationconnectionValidation: blobStorageEndpointConnectionValidationOptions(),});+};const processBlobStorageExport = async (config: {projectId: string;@@ -796,7 +821,8 @@ const processBlobStorageExport = async (config: {partFailures: 0,};const producesUploadStats =- config.type !== BlobStorageIntegrationType.AZURE_BLOB_STORAGE &&+ (config.type === BlobStorageIntegrationType.S3 ||+ config.type === BlobStorageIntegrationType.S3_COMPATIBLE) &&sharedEnv.LANGFUSE_S3_UPLOAD_ENABLE_BUFFERED === "true";let uploadStartMs: number | undefined;let uploadDurationMsFinal: number | undefined;diff --git a/worker/src/features/integrations/customerFaultClassification.test.ts b/worker/src/features/integrations/customerFaultClassification.test.tsindex 2657a26d7b..339d7fe5df 100644--- a/worker/src/features/integrations/customerFaultClassification.test.ts+++ b/worker/src/features/integrations/customerFaultClassification.test.ts@@ -106,6 +106,20 @@ describe("isCustomerFaultError", () => {true,);});++ it("classifies a GCS default-credentials bucket rejection as bucket_or_container", () => {+ const err = Object.assign(new Error("not allowed"), {+ name: "GcsBucketNotAllowedError",+ });+ expect(classifyCustomerFault(err)).toBe("bucket_or_container");+ });+ });++ it("classifies a non-JSON GCS key as credentials", () => {+ const err = Object.assign(new Error("not a key"), {+ name: "InvalidGcsServiceAccountKey",+ });+ expect(classifyCustomerFault(err)).toBe("credentials");});describe("customer_fault — bare HTTP status", () => {diff --git a/worker/src/features/integrations/customerFaultClassification.ts b/worker/src/features/integrations/customerFaultClassification.tsindex 216752187b..769e0cc262 100644--- a/worker/src/features/integrations/customerFaultClassification.ts+++ b/worker/src/features/integrations/customerFaultClassification.ts@@ -35,6 +35,8 @@ const CREDENTIAL_FAULT_CODES = new Set<string>(["InvalidAuthenticationInfo","AccountIsDisabled","InsufficientAccountPermissions",+ // GCS — stored secret is not a service account JSON key (worker guard)+ "InvalidGcsServiceAccountKey",]);const BUCKET_FAULT_CODES = new Set<string>([@@ -44,6 +46,8 @@ const BUCKET_FAULT_CODES = new Set<string>([// Azure — container & path"ContainerNotFound","InvalidResourceName",+ // GCS — bucket not allowed for default credentials (Langfuse guard)+ "GcsBucketNotAllowedError",]);// Langfuse outbound-URL / SSRF validation rejections (OutboundUrlValidationError