microsoftgraph / msgraph-sdk-java

Microsoft Graph SDK for Java
https://docs.microsoft.com/en-us/graph/sdks/sdks-overview
MIT License
403 stars 134 forks source link

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

Open SashaUsov opened 1 month ago

SashaUsov commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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?

Ndiritu commented 1 month ago

@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.