Skip to content

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

fix(ai-gateway): allow deleting the ingestion project once ingestion is None (#19434)

Tobias Wochingerebed92e221e9
diff --git a/web/src/__tests__/server/ai-gateway-control-plane.servertest.ts b/web/src/__tests__/server/ai-gateway-control-plane.servertest.ts
index ff9e6c6d18..59ce3908a9 100644
--- a/web/src/__tests__/server/ai-gateway-control-plane.servertest.ts
+++ b/web/src/__tests__/server/ai-gateway-control-plane.servertest.ts
@@ -2105,12 +2105,33 @@ describe("AI gateway control plane", () => {
).resolves.toEqual({ isGatewayIngestionProject: true });
await expect(
caller.projects.delete({ projectId: project.id }),
- ).rejects.toThrow("Select another ingestion project before deleting it");
+ ).rejects.toThrow(
+ "Select another ingestion project or set the ingestion mode to None before deleting it",
+ );
await expect(
prisma.project.findUnique({ where: { id: project.id } }),
).resolves.toMatchObject({ deletedAt: null });
});
+ it("allows deleting the linked ingestion project while ingestion is NONE", async () => {
+ const { caller, org, project } = await prepare();
+ await caller.aiGateway.updateConfig({
+ orgId: org.id,
+ defaultIngestionProjectId: project.id,
+ ingestionMode: "NONE",
+ });
+
+ await expect(
+ caller.projects.deletionProtection({ projectId: project.id }),
+ ).resolves.toEqual({ isGatewayIngestionProject: false });
+ await expect(
+ caller.projects.delete({ projectId: project.id }),
+ ).resolves.toBe(true);
+ await expect(
+ prisma.project.findUnique({ where: { id: project.id } }),
+ ).resolves.toMatchObject({ deletedAt: expect.any(Date) });
+ });
+
it("blocks resolve after the default ingestion project is deleted", async () => {
const { caller, org, project } = await prepare();
await caller.aiGateway.updateConfig({
diff --git a/web/src/__tests__/server/apiKeyCacheInvalidation.servertest.ts b/web/src/__tests__/server/apiKeyCacheInvalidation.servertest.ts
index 6af491785d..66527118ec 100644
--- a/web/src/__tests__/server/apiKeyCacheInvalidation.servertest.ts
+++ b/web/src/__tests__/server/apiKeyCacheInvalidation.servertest.ts
@@ -390,7 +390,7 @@ describe("API-key cache invalidation on project/org lifecycle", () => {
expect(res.statusCode).toBe(409);
expect(res.body).toEqual({
message:
- "This project is used as the AI Gateway ingestion project. Select another ingestion project before deleting it.",
+ "This project is used as the AI Gateway ingestion project. Select another ingestion project or set the ingestion mode to None before deleting it.",
});
expect(await survivingKeys(keys)).toEqual(keys);
await expect(
diff --git a/web/src/ee/features/admin-api/server/projects/projectById/index.ts b/web/src/ee/features/admin-api/server/projects/projectById/index.ts
index c5f7d75d2a..eb45ea770e 100644
--- a/web/src/ee/features/admin-api/server/projects/projectById/index.ts
+++ b/web/src/ee/features/admin-api/server/projects/projectById/index.ts
@@ -124,13 +124,15 @@ export async function handleDeleteProject(
where: {
organizationId: scope.orgId,
defaultIngestionProjectId: projectId,
+ // With ingestion NONE the project is only remembered, not written to.
+ ingestionMode: { not: "NONE" },
},
select: { organizationId: true },
});
if (gatewayConfig) {
return res.status(409).json({
message:
- "This project is used as the AI Gateway ingestion project. Select another ingestion project before deleting it.",
+ "This project is used as the AI Gateway ingestion project. Select another ingestion project or set the ingestion mode to None before deleting it.",
});
}
diff --git a/web/src/features/projects/ProjectSettingsPage.tsx b/web/src/features/projects/ProjectSettingsPage.tsx
index 27deeabeb7..54d4debea0 100644
--- a/web/src/features/projects/ProjectSettingsPage.tsx
+++ b/web/src/features/projects/ProjectSettingsPage.tsx
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-use-before-define */
import Header from "@/src/components/layouts/header";
import { ApiKeyList } from "@/src/features/public-api/components/ApiKeyList";
-import { DeleteProjectDialogController } from "@/src/features/projects/components/DeleteProjectDialogController";
+import { DeleteProjectDialogController } from "@/src/features/projects/components/DeleteProjectDialogController/DeleteProjectDialogController";
import { HostNameProject } from "@/src/features/projects/components/HostNameProject";
import RenameProject from "@/src/features/projects/components/RenameProject";
import { Button } from "@/src/components/ui/button";
diff --git a/web/src/features/projects/components/DeleteProjectDialogController.tsx b/web/src/features/projects/components/DeleteProjectDialogController/DeleteProjectDialogController.tsx
similarity index 91%
rename from web/src/features/projects/components/DeleteProjectDialogController.tsx
rename to web/src/features/projects/components/DeleteProjectDialogController/DeleteProjectDialogController.tsx
index 62420c84dc..267d20321b 100644
--- a/web/src/features/projects/components/DeleteProjectDialogController.tsx
+++ b/web/src/features/projects/components/DeleteProjectDialogController/DeleteProjectDialogController.tsx
@@ -9,7 +9,7 @@ import { usePostHogClientCapture } from "@/src/features/posthog-analytics";
import { useQueryProject } from "@/src/features/projects/hooks";
import { useHasProjectAccess } from "@/src/features/rbac";
import { api, reportNonTrpcError } from "@/src/utils/api";
-import { DeleteProjectDialog } from "./DeleteProjectDialog";
+import { DeleteProjectDialog } from "@/src/features/projects/components/DeleteProjectDialogController/components/DeleteProjectDialog/DeleteProjectDialog";
type DeleteProjectDialogControllerProps = {
children: (control: {
@@ -61,7 +61,7 @@ export function DeleteProjectDialogController({
return (
<Dialog
title="Project cannot be deleted"
- text="This project is used as the AI Gateway ingestion project. Select another ingestion project before deleting it."
+ text="This project is used as the AI Gateway ingestion project. Select another ingestion project or set the ingestion mode to None before deleting it."
actions={[
{
label: "Open AI Gateway settings",
diff --git a/web/src/features/projects/components/DeleteProjectDialog.stories.tsx b/web/src/features/projects/components/DeleteProjectDialogController/components/DeleteProjectDialog/DeleteProjectDialog.stories.tsx
similarity index 100%
rename from web/src/features/projects/components/DeleteProjectDialog.stories.tsx
rename to web/src/features/projects/components/DeleteProjectDialogController/components/DeleteProjectDialog/DeleteProjectDialog.stories.tsx
diff --git a/web/src/features/projects/components/DeleteProjectDialog.tsx b/web/src/features/projects/components/DeleteProjectDialogController/components/DeleteProjectDialog/DeleteProjectDialog.tsx
similarity index 100%
rename from web/src/features/projects/components/DeleteProjectDialog.tsx
rename to web/src/features/projects/components/DeleteProjectDialogController/components/DeleteProjectDialog/DeleteProjectDialog.tsx
diff --git a/web/src/features/projects/server/projectsRouter.ts b/web/src/features/projects/server/projectsRouter.ts
index a1b970b56f..0a4624d4b8 100644
--- a/web/src/features/projects/server/projectsRouter.ts
+++ b/web/src/features/projects/server/projectsRouter.ts
@@ -416,6 +416,8 @@ async function isGatewayIngestionProject(params: {
where: {
organizationId: params.organizationId,
defaultIngestionProjectId: params.projectId,
+ // With ingestion NONE the project is only remembered, not written to.
+ ingestionMode: { not: "NONE" },
},
select: { organizationId: true },
});
@@ -429,7 +431,7 @@ async function throwIfGatewayIngestionProject(params: {
}) {
if (await isGatewayIngestionProject(params)) {
throw new LangfuseConflictError(
- "This project is used as the AI Gateway ingestion project. Select another ingestion project before deleting it.",
+ "This project is used as the AI Gateway ingestion project. Select another ingestion project or set the ingestion mode to None before deleting it.",
);
}
}