Fix infinite loop on error in user group fetch request#21597
Fix infinite loop on error in user group fetch request#21597laurenastrid1 wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves reliability of Azure AD group fetching by ensuring the Microsoft Graph pagination loop exits when a request fails, preventing a potential infinite loop during group enumeration.
Changes:
- Exit the
while (nextUrl)pagination loop whenmakeGetRequestthrows, rather than continuing with an unchangednextUrl.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PR Changes
|
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (0.00%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #21597 +/- ##
==========================================
- Coverage 72.85% 72.85% -0.01%
==========================================
Files 331 331
Lines 99070 99071 +1
Branches 5546 5546
==========================================
Hits 72175 72175
- Misses 26895 26896 +1
🚀 New features to boost your workflow:
|
| nextUrl = response.data["@odata.nextLink"]; | ||
| } catch (error) { | ||
| console.error("Error fetching user groups:", error); | ||
| break; // Exit the loop on error |
There was a problem hiding this comment.
I'm not familiar with the response here; but presumably response.data["@odata.nextLink"] won't work in the next iteration?
Or in other words, if response.data["@odata.nextLink"] may work to get groups, should we set nextUrl in the catch block and try again?
There was a problem hiding this comment.
Two things that we need to handle here:
- if getting the response throws
- if parsing the response throws
Probably need multiple try-catch blocks in here
Description
Code Changes Checklist
npm run test)Reviewers: Please read our reviewer guidelines