diff --git a/backend/packages/Upgrade/src/api/services/SegmentService.ts b/backend/packages/Upgrade/src/api/services/SegmentService.ts index 4b8b907385..cc94637388 100644 --- a/backend/packages/Upgrade/src/api/services/SegmentService.ts +++ b/backend/packages/Upgrade/src/api/services/SegmentService.ts @@ -229,7 +229,7 @@ export class SegmentService { // create/update segment document segment.id = segment.id || uuid(); const { id, name, description, context, type } = segment; - const allSegments = await this.segmentRepository.getAllSegments(logger); + const allSegments = await this.getSegmentByIds(segment.subSegmentIds); const subSegmentData = segment.subSegmentIds .filter((subSegmentId) => { // check if segment exists: diff --git a/backend/packages/Upgrade/test/unit/services/SegmentService.test.ts b/backend/packages/Upgrade/test/unit/services/SegmentService.test.ts index 1e53673eb1..cf4c30cdcd 100644 --- a/backend/packages/Upgrade/test/unit/services/SegmentService.test.ts +++ b/backend/packages/Upgrade/test/unit/services/SegmentService.test.ts @@ -267,7 +267,7 @@ describe('Segment Service Testing', () => { it('should upsert a segment with no id', async () => { const err = new Error('error'); const segment = new SegmentInputValidator(); - segment.subSegmentIds = ['seg3']; + segment.subSegmentIds = ['seg1']; segment.userIds = []; segment.groups = []; repo.findOne = jest.fn().mockResolvedValue(seg2);