Handle permissions API errors gracefully in UpdateUserScopesAsync#1571
Open
waldekmastykarz wants to merge 3 commits intodotnet:mainfrom
Open
Handle permissions API errors gracefully in UpdateUserScopesAsync#1571waldekmastykarz wants to merge 3 commits intodotnet:mainfrom
waldekmastykarz wants to merge 3 commits intodotnet:mainfrom
Conversation
When the permissions API returns a 404 for an unrecognized Graph endpoint, the exception from that single call no longer causes the entire Task.WhenAll to fail. Instead, the error is logged as a warning and the endpoint is skipped, allowing the remaining permissions to be reported correctly. Fixes dotnet#1565 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the resilience of Graph minimal-permissions scope calculation by preventing a single failing permissions-API call (e.g., 404 for an unrecognized endpoint) from breaking the entire scope-update flow in UpdateUserScopesAsync.
Changes:
- Wrap individual
GetFromJsonAsynccalls inUpdateUserScopesAsyncwithHttpRequestExceptionhandling so failures are logged and skipped. - Allow remaining successful permissions lookups to continue so minimal permissions can still be reported.
Materialize the task collection with ToArray() and iterate the results from Task.WhenAll instead of re-enumerating the deferred Select, which would trigger duplicate HTTP calls. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the permissions API returns a 404 for an unrecognized Graph endpoint (e.g.
/users/{email}/mailFolders/inbox), theHttpRequestExceptionfrom that single call caused the entireTask.WhenAllinUpdateUserScopesAsyncto fail. This bubbled up toDetermineMinimalScopesAsync, which caught the exception and returnednull, preventing all permissions from being reported.This fix wraps individual HTTP calls with error handling so that a failed request is logged as a warning and skipped, allowing the remaining permissions to be reported correctly.
Fixes #1565