Skip to content

Commit da50bad

Browse files
committed
fix: repository groups crashing defaults
Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
1 parent 20774b1 commit da50bad

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

backend/src/services/collectionService.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,22 +438,23 @@ export class CollectionService extends LoggerBase {
438438
insightsProjectId: string,
439439
repositoryGroups: ICreateRepositoryGroup[],
440440
): Promise<IRepositoryGroup[]> {
441+
const rg = repositoryGroups || []
441442
// Get existing repository groups for the given insights project
442443
const existingRepositoryGroups = await listRepositoryGroups(qx, { insightsProjectId })
443444

444445
// Extract IDs of existing repository groups
445446
const existingIds: string[] = existingRepositoryGroups.map((rg) => rg.id)
446447

447448
// Extract IDs of repository groups to be synchronized
448-
const repositoryGroupIds: string[] = repositoryGroups.map((rg) => rg.id) as string[]
449+
const repositoryGroupIds: string[] = rg.map((rg) => rg.id) as string[]
449450

450451
// Find repository groups that need to be updated (exist in both lists)
451-
const toUpdate: ICreateRepositoryGroup[] = repositoryGroups.filter((rg) =>
452+
const toUpdate: ICreateRepositoryGroup[] = rg.filter((rg) =>
452453
existingIds.includes(rg.id),
453454
)
454455

455456
// Find repository groups that need to be created (don't exist or have no ID)
456-
const toCreate: ICreateRepositoryGroup[] = repositoryGroups.filter(
457+
const toCreate: ICreateRepositoryGroup[] = rg.filter(
457458
(rg) => !rg.id || !existingIds.includes(rg.id),
458459
)
459460

0 commit comments

Comments
 (0)