Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix(project): use BadRequestError for the secret scanning project limit

Claude69571f2c608a
diff --git a/backend/src/services/project/project-service.test.ts b/backend/src/services/project/project-service.test.ts
index 7262e93f25..d516f3340e 100644
--- a/backend/src/services/project/project-service.test.ts
+++ b/backend/src/services/project/project-service.test.ts
@@ -1,7 +1,7 @@
import { describe, expect, test, vi } from "vitest";
import { OrgMembershipStatus, ProjectType } from "@app/db/schemas";
-import { ConflictError } from "@app/lib/errors";
+import { BadRequestError } from "@app/lib/errors";
import { ActorType } from "@app/services/auth/auth-type";
import { projectServiceFactory } from "./project-service";
@@ -155,11 +155,11 @@ describe("secret scanning project uniqueness", () => {
type: ProjectType.SecretScanning
});
- test("rejects a second secret scanning project in the same organization with a conflict", async () => {
+ test("rejects a second secret scanning project in the same organization", async () => {
const { service, projectDAL } = setup();
projectDAL.find.mockResolvedValue([{ id: "existing-scanning-project" }]);
- await expect(createSecretScanningProject(service)).rejects.toThrow(ConflictError);
+ await expect(createSecretScanningProject(service)).rejects.toThrow(BadRequestError);
await expect(createSecretScanningProject(service)).rejects.toThrow(
"Secret Scanning is limited to one project per organization at this time."
);
@@ -169,7 +169,7 @@ describe("secret scanning project uniqueness", () => {
const { service, projectDAL, tx } = setup();
projectDAL.find.mockResolvedValue([{ id: "existing-scanning-project" }]);
- await expect(createSecretScanningProject(service)).rejects.toThrow(ConflictError);
+ await expect(createSecretScanningProject(service)).rejects.toThrow(BadRequestError);
expect(projectDAL.find).toHaveBeenCalledExactlyOnceWith(
{ orgId: "root", type: ProjectType.SecretScanning },
diff --git a/backend/src/services/project/project-service.ts b/backend/src/services/project/project-service.ts
index e94ce3b2c4..c0b3c28206 100644
--- a/backend/src/services/project/project-service.ts
+++ b/backend/src/services/project/project-service.ts
@@ -50,7 +50,7 @@ import { getProcessedPermissionRules } from "@app/lib/casl/permission-filter-uti
import { getConfig } from "@app/lib/config/env";
import { crypto } from "@app/lib/crypto/cryptography";
import { DatabaseErrorCode } from "@app/lib/error-codes";
-import { BadRequestError, ConflictError, DatabaseError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";
+import { BadRequestError, DatabaseError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";
import { groupBy } from "@app/lib/fn";
import { alphaNumericNanoId } from "@app/lib/nanoid";
import { requestMemoKeys } from "@app/lib/request-context/memo-keys";
@@ -311,7 +311,7 @@ export const projectServiceFactory = ({
);
if (existingSecretScanningProject) {
- throw new ConflictError({
+ throw new BadRequestError({
message: "Secret Scanning is limited to one project per organization at this time."
});
}