Skip to content

Commit 605ce26

Browse files
committed
fix: address review feedback
- Restructure the Entra group pagination loop guard-first: check the page cap and warn/break before doing the request, per review. - Reword the changelog entry for the pagination fix.
1 parent 00d7fe3 commit 605ce26

2 files changed

Lines changed: 16 additions & 17 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ All notable changes to this project will be documented in this file.
2727

2828
### Fixed
2929

30-
- The Entra user-info-fetcher backend now follows Microsoft Graph's `@odata.nextLink` pagination,
31-
so users with more group memberships than fit on a single response page receive their complete
32-
group list. Following the link is bounded to 100 pages as a safeguard ([#859]).
30+
- The user-info-fetcher Entra backend now follows Microsoft Graph's `@odata.nextLink` pagination
31+
links - up to 100 times - to fetch 999 group memberships per result page, resulting in a maximum
32+
of 99900 fetched memberships for a single user ([#859]).
3333

3434
### Removed
3535

rust/user-info-fetcher/src/backend/entra.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,19 @@ impl ResolvedEntraBackend {
230230
let mut pages_remaining = MAX_GROUP_PAGES;
231231

232232
while let Some(url) = next_url {
233+
// Bound the loop so we can't run into an infinite loop for any reason
234+
if pages_remaining == 0 {
235+
tracing::warn!(
236+
user.id = %user_info.id,
237+
max_pages = MAX_GROUP_PAGES,
238+
"reached the maximum number of Entra group membership pages; \
239+
the resolved group list may be incomplete"
240+
);
241+
242+
break;
243+
}
244+
pages_remaining -= 1;
245+
233246
let response = send_json_request::<GroupMembershipResponse>(
234247
self.http_client.get(url).bearer_auth(&authn.access_token),
235248
)
@@ -245,20 +258,6 @@ impl ResolvedEntraBackend {
245258
.next_link
246259
.map(|next_link| entra_backend.next_page(&next_link))
247260
.transpose()?;
248-
249-
// Bound the loop so we can't run into an infinite loop for any reason
250-
pages_remaining -= 1;
251-
if pages_remaining == 0 {
252-
if next_url.is_some() {
253-
tracing::warn!(
254-
user.id = %user_info.id,
255-
max_pages = MAX_GROUP_PAGES,
256-
"reached the maximum number of Entra group membership pages; \
257-
the resolved group list may be incomplete"
258-
);
259-
}
260-
break;
261-
}
262261
}
263262

264263
Ok(UserInfo {

0 commit comments

Comments
 (0)