microsoftgraph / microsoft-graph-toolkit

Authentication Providers and UI components for Microsoft Graph 🦒
https://docs.microsoft.com/graph/toolkit/overview
Other
945 stars 303 forks source link

[BUG] PeoplePicker - Request_UnsupportedQuery #2068

Closed thanhnguyen0504 closed 8 months ago

thanhnguyen0504 commented 1 year ago

Describe the bug

To Reproduce Steps to reproduce the behavior:

  1. I'm using PeoplePicker component of @microsoft/mgt-react 2.9.0

` <> <PeoplePicker selectedPeople={filteredPickedPeople} showMax={5} userType={UserType.user} userFilters="userType ne 'Guest'" selectionChanged={onSelectionChanged} className={getMgtClassName(themeInfo.themeName)}

</>`

  1. When I click on the search box with empty text. The component make an request to GraphAPI

curl 'https://graph.microsoft.com/v1.0/users?$top=6&$filter=userType%20ne%20%27Guest%27' \ -H 'Accept: */*' \ -H 'Accept-Language: vi-VN,vi;q=0.9,en-US;q=0.8,en;q=0.7,fr-FR;q=0.6,fr;q=0.5' \ -H 'Authorization: Bearer cannotsharewithyou\ -H 'Connection: keep-alive' \ -H 'Origin: https://teamsappstage.limeade.io' \ -H 'Referer: https://teamsappstage.limeade.io/' \ -H 'SdkVersion: MGT-PEOPLE-PICKER/2.9.0, MgtTeamsMsal2Provider/2.9.0, mgt/2.9.0, graph-js/2.2.1 (featureUsage=6)' \ -H 'Sec-Fetch-Dest: empty' \ -H 'Sec-Fetch-Mode: cors' \ -H 'Sec-Fetch-Site: cross-site' \ -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36' \ -H 'client-request-id: 577b7913-d416-e88f-55d9-67b8654c946f' \ -H 'sec-ch-ua: "Chromium";v="110", "Not A(Brand";v="24", "Google Chrome";v="110"' \ -H 'sec-ch-ua-mobile: ?0' \ -H 'sec-ch-ua-platform: "Windows"' \ --compressed

  1. That API return Status Code: 400 Bad Request and the error:

{"error":{"code":"Request_UnsupportedQuery","message":"Unsupported or invalid query filter clause specified for property 'userType' of resource 'User'.","innerError":{"date":"2023-03-02T08:12:56","request-id":"aea3b0e1-c57d-4d81-9c46-950e4c4cb470","client-request-id":"577b7913-d416-e88f-55d9-67b8654c946f"}}}

  1. I investigated and found that, to fix the issue, the request header should have ConsistencyLevel: eventual and add Add “$count=true” to the query. Detail here: https://github.com/microsoftgraph/microsoft-graph-docs-contrib/issues/8302

Expected behavior Should not return error and should show all users if I click to searchbox with empty text

Screenshots

I'm using PeoplePicker image

This is the issue image

Environment (please complete the following information):

Additional context Add any other context about the problem here.

ghost commented 1 year ago

Hello thanhnguyen0504, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

gavinbarron commented 1 year ago

Thanks for raising this @thanhnguyen0504 and also thanks for the research and pointer on $count and the consistency level.

Would you mind submitting a PR for this? The small internal team we have is working hard to get our v3.0.0 release ready for GA.

The one thing I will say is that using the eventual consistency header approach is that is an expensive call and will increase the likelihood of throttling within that tenant, so I'd prefer a solution that added a way for these additional parameters to be added only when the developer explicitly enables that mode of calling Graph.

sebastienlevert commented 8 months ago

This should have been fixed since the release of v3. Please update your app and report back here here you think we should reconsider it. Thanks!