-
Notifications
You must be signed in to change notification settings - Fork 288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] mgt-people-picker: Invalid $filter when using people-filters #2738
Comments
Hi @SYoungWSP. What scopes/permissions does the user have when running those queries? If you have only requested |
Hi @gavinbarron, In my app I have I'm not sure how it works in the Toolkit Playground but the error is the same there. If I try from Graph Explorer with the default permissions it works. Thanks |
You will need |
Hi, #2624 is talking about Thanks |
Oh! Wait a second! I just saw the issue. It seems that we are double filtering and building an invalid $filter query.
We can see that we're filtering 2 times on personType/class and we have an issue with string concatenation. It would be somewhere here: https://github.com/microsoftgraph/microsoft-graph-toolkit/blob/main/packages/mgt-components/src/graph/graph.people.ts#L194 Sorry, I totally missed it the first time 😮 Would you be interested to send us a PR and we could review / help with it? Thanks! |
Hi, I've never made a PR before but I can try. Looking at the file you linked it looks like
+= but also including the existing value.
|
You're absolutely right. It seems where the issue is! Good catch! Feel free to submit a PR, we'll gladly review it! |
I am trying to exclude Personal Contacts from the mgt-people-picker results in a corporate application.
The following filter works through Graph Explorer (https://developer.microsoft.com/en-us/graph/graph-explorer).
https://graph.microsoft.com/v1.0/me/people?$search=young&$filter=personType/class+eq+'Person'and+personType/subclass+eq+'OrganizationUser'$filter=personType/class+eq+'Person'and+personType/subclass+eq+'OrganizationUser'
If I add the filter to the mgt-people-picker's
people-filters
attribute I get no results and can see a 400 response from the Graph API call.Graph API call made by the component:
https://graph.microsoft.com/v1.0/me/people?$search=%22young%22&$top=6&$filter=personType/class%20eq%20%27Person%27personType/class%20eq%20%27Person%27%20and%20personType/class%20eq%20%27Person%27%20and%20personType/subclass%20eq%20%27OrganizationUser%27
I notice that
personType/class eq 'Person'
is automatically added to the query when using thepeople-filters
attribute so I shortened the filter topersonType/subclass eq 'OrganizationUser'
to avoid repetition however it looks like:https://graph.microsoft.com/v1.0/me/people?$search=%22young%22&$top=6&$filter=personType/class%20eq%20%27Person%27personType/class%20eq%20%27Person%27%20and%20personType/subclass%20eq%20%27OrganizationUser%27
Steps to reproduce
I recreated it using Microsoft Graph Toolkit Playground (https://mgt.dev/?path=/story/components-mgt-people-picker-properties--picker-people-filters) with version 3.1.1 and then realised even the straight example has the same problem.
No results returned.
Request:
https://graph.microsoft.com/v1.0/me/people?$search="ale"&$top=6&$filter=personType/class eq 'Person'personType/class eq 'Person' and jobTitle eq 'Web Marketing Manager'
Response: 400
"Invalid filter clause: Syntax error at position 38 in 'personType/class eq 'Person'personType/class eq 'Person' and jobTitle eq 'Web Marketing Manager''."
Expected behavior
If personType filter specified in
people-filters
don't append again. Ensure 'and' is added before anypeople-filters
to create a valid $filter.Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: