From 1308e9c599a3e441abc702b430ba62df55a94bff Mon Sep 17 00:00:00 2001 From: Mathis HERRIOT <197931332+0x485254@users.noreply.github.com> Date: Sat, 17 May 2025 00:12:39 +0200 Subject: [PATCH] fix(projects): handle non-array collaborators in service to prevent errors --- backend/src/modules/projects/services/projects.service.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/src/modules/projects/services/projects.service.ts b/backend/src/modules/projects/services/projects.service.ts index 9ed9160..c1afb05 100644 --- a/backend/src/modules/projects/services/projects.service.ts +++ b/backend/src/modules/projects/services/projects.service.ts @@ -247,6 +247,11 @@ export class ProjectsService { .innerJoin(schema.users, eq(schema.projectCollaborators.userId, schema.users.id)) .where(eq(schema.projectCollaborators.projectId, projectId)); + // Ensure collaborators is an array before mapping + if (!Array.isArray(collaborators)) { + return []; + } + // Map the results to extract just the user objects return collaborators.map(collaborator => collaborator.user); } catch (error) {