fix(projects): handle non-array collaborators in service to prevent errors

This commit is contained in:
Mathis HERRIOT
2025-05-17 00:12:39 +02:00
parent b7d899e66e
commit 1308e9c599

View File

@@ -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) {