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
No known key found for this signature in database
GPG Key ID: E7EB4A211D8D4907

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