msgraph-sdk-java icon indicating copy to clipboard operation
msgraph-sdk-java copied to clipboard

Microsoft Graph Java SDK v.6.16.0 return empty site list with "*" and ""(empty) search query parameter

Open SashaUsov opened this issue 1 year ago • 3 comments

Describe the bug

Create GraphServiceClient with UsernamePasswordCredential provider

var provider = new UsernamePasswordCredentialBuilder()
                .clientId("client_id")
                .username("username")
                .password("password");
var graphClient = new GraphServiceClient(provider);

Call graphClient.sites().get().getValue()

Expected result: receive a list of the sites Actual result: an empty list was returned without any error.

GraphServiceClient with ClientSecretCredential provider works as expected on graphClient.sites().get().getValue() call.

SDK Version

6.16.0

SashaUsov avatar Oct 02 '24 15:10 SashaUsov

Make some additional queries:

  1. Search query like "*":
graphServiceClient.sites()
                .get(requestConfiguration -> {
                    var queryParameters = requestConfiguration.queryParameters;
                        queryParameters.select = new String[]{SELECT_SITE_NAME};
                        queryParameters.search = "*";
                })
.getValue()

Expected: get list of sites Actual result: com.microsoft.graph.models.odataerrors.ODataError: Syntax error: character '*' is not valid at position 0 in '*'.

  1. Search query empty "":
graphServiceClient.sites()
                .get(requestConfiguration -> {
                    var queryParameters = requestConfiguration.queryParameters;
                        queryParameters.select = new String[]{SELECT_SITE_NAME};
                        queryParameters.search = "";
                })
.getValue()

Expected: get list of sites Actual result: com.microsoft.graph.models.odataerrors.ODataError: Expression expected at position 0 in ''.

  1. Search query like "all":
graphServiceClient.sites()
                .get(requestConfiguration -> {
                    var queryParameters = requestConfiguration.queryParameters;
                        queryParameters.select = new String[]{SELECT_SITE_NAME};
                        queryParameters.search = "all";
                })
.getValue()

Expected: get list of sites Actual result: got 3 sites instead 99

Java SDK v5.80.0 request with same client_id and user:

graphServiceClient
                .sites()
                .buildRequest(new QueryOption("search", "*"), new QueryOption("select", "id,name"))
                .get()
                .getCurrentPage()

Expected: get list of sites Actual result: got 99 sites

SashaUsov avatar Oct 03 '24 07:10 SashaUsov

Work solution: https://github.com/microsoftgraph/msgraph-sdk-java/issues/2090#issuecomment-2390888773

Please tell me, will this bug be fixed in the next SDK releases?

SashaUsov avatar Oct 03 '24 09:10 SashaUsov

@SashaUsov this will need to be prioritized against other issues. For now, it's likely that it won't make it into the next release. I'm also unable to reproduce the behaviour and would need further investigation here.

In the meantime, using withUrl() should help until this is resolved.

Ndiritu avatar Oct 07 '24 23:10 Ndiritu