Skip to content

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

fix(web): emit audit log for public blob storage deletion (#13517)

Max Deichmann9b7daaf7040f
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 d7fa2f96cc..e68ae19d47 100644
--- a/web/src/__tests__/server/blob-storage-integration-api.servertest.ts
+++ b/web/src/__tests__/server/blob-storage-integration-api.servertest.ts
@@ -67,6 +67,7 @@ describe("Blob Storage Integrations API", () => {
let testProject2Id: string;
let testApiKey: string;
let testApiSecretKey: string;
+ let testApiKeyId: string;
let otherOrgId: string;
let otherProjectId: string;
@@ -110,6 +111,7 @@ describe("Blob Storage Integrations API", () => {
});
testApiKey = orgApiKey.publicKey;
testApiSecretKey = orgApiKey.secretKey;
+ testApiKeyId = orgApiKey.id;
// Create another organization for cross-org tests
const otherOrg = await prisma.organization.create({
@@ -612,6 +614,34 @@ describe("Blob Storage Integrations API", () => {
expect(deletedIntegration).toBeNull();
});
+ it("should create an audit log entry for delete", async () => {
+ const auditLogWhere = {
+ resourceType: "blobStorageIntegration",
+ resourceId: testIntegrationId,
+ action: "delete",
+ orgId: testOrgId,
+ projectId: testIntegrationId,
+ apiKeyId: testApiKeyId,
+ };
+ const auditLogCountBefore = await prisma.auditLog.count({
+ where: auditLogWhere,
+ });
+
+ await makeZodVerifiedAPICall(
+ BlobStorageIntegrationDeletionResponseSchema,
+ "DELETE",
+ `/api/public/integrations/blob-storage/${testIntegrationId}`,
+ undefined,
+ createBasicAuthHeader(testApiKey, testApiSecretKey),
+ 200,
+ );
+
+ const auditLogCountAfter = await prisma.auditLog.count({
+ where: auditLogWhere,
+ });
+ expect(auditLogCountAfter).toBe(auditLogCountBefore + 1);
+ });
+
it("should return 404 for non-existent integration", async () => {
const nonExistentId = randomUUID();
const result = await makeAPICall(
diff --git a/web/src/pages/api/public/integrations/blob-storage/[id].ts b/web/src/pages/api/public/integrations/blob-storage/[id].ts
index 09ec760a64..6bacd9b2ad 100644
--- a/web/src/pages/api/public/integrations/blob-storage/[id].ts
+++ b/web/src/pages/api/public/integrations/blob-storage/[id].ts
@@ -4,6 +4,7 @@ import { prisma } from "@langfuse/shared/src/db";
import { redis } from "@langfuse/shared/src/server";
import { type NextApiRequest, type NextApiResponse } from "next";
import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";
+import { auditLog } from "@/src/features/audit-logs/auditLog";
import {
InvalidRequestError,
LangfuseNotFoundError,
@@ -77,6 +78,15 @@ async function handleDeleteBlobStorageIntegration(
where: { projectId: id },
});
+ await auditLog({
+ action: "delete",
+ resourceType: "blobStorageIntegration",
+ resourceId: integration.projectId,
+ projectId: integration.projectId,
+ orgId: authCheck.scope.orgId,
+ apiKeyId: authCheck.scope.apiKeyId,
+ });
+
return res.status(200).json({
message: "Blob storage integration successfully deleted",
});