fix: pass $select when fetching group members to prevent sparse objects

Without $select, Microsoft Graph returns only id and @odata.type for
group members, which causes defaultUserTransformer/defaultGroupTransformer
to return undefined and silently drop membership refs. Requesting the
minimum fields needed by both transformers ensures member objects always
have enough data to produce stable entity refs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: pillaris <pillaris@adobe.com>
This commit is contained in:
pillaris
2026-04-27 14:29:41 +05:30
parent 6fa66e7907
commit ac04bb696d
2 changed files with 22 additions and 0 deletions
@@ -586,6 +586,17 @@ describe('MicrosoftGraphIncrementalEntityProvider', () => {
expect(groupEntity!.entity.spec?.members).toContain(
'user:default/alice_example.com',
);
// Verify $select is passed so member objects are never sparse
expect(mockClient.getGroupMembers).toHaveBeenCalledWith(
'grp-1',
expect.objectContaining({
select: expect.arrayContaining([
'id',
'displayName',
'userPrincipalName',
]),
}),
);
});
it('populates spec.children with nested group refs from getGroupMembers', async () => {
@@ -429,6 +429,17 @@ export class MicrosoftGraphIncrementalEntityProvider
for await (const member of client.getGroupMembers(group.id!, {
top: GROUP_PAGE_SIZE,
// Request the minimum fields needed by defaultUserTransformer and
// defaultGroupTransformer so member objects are never sparse.
select: [
'id',
'displayName',
'mail',
'mailNickname',
'userPrincipalName',
'description',
'securityEnabled',
],
})) {
if (member['@odata.type'] === '#microsoft.graph.user') {
try {