From f7122c21fd62b3d50e046a01eca3b38596d5000b Mon Sep 17 00:00:00 2001 From: Daniel Hougaard <62331820+DanielHougaard@users.noreply.github.com> Date: Mon, 25 Mar 2024 21:43:08 +0100 Subject: [PATCH] Fix: Allow query function to be called with undefined orgId, and handle it as an error --- backend/src/services/project/project-dal.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/src/services/project/project-dal.ts b/backend/src/services/project/project-dal.ts index 369e005ac..4f4225344 100644 --- a/backend/src/services/project/project-dal.ts +++ b/backend/src/services/project/project-dal.ts @@ -168,8 +168,12 @@ export const projectDALFactory = (db: TDbClient) => { } }; - const findProjectBySlug = async (slug: string, orgId: string) => { + const findProjectBySlug = async (slug: string, orgId: string | undefined) => { try { + if (!orgId) { + throw new BadRequestError({ message: "Organization ID is required when querying with slugs" }); + } + const projects = await db(TableName.ProjectMembership) .where(`${TableName.Project}.slug`, slug) .where(`${TableName.Project}.orgId`, orgId)