github-api icon indicating copy to clipboard operation
github-api copied to clipboard

PagedSearchIterable returns a subset of the searched results and has non-deterministic behaviour.

Open tassiluca opened this issue 3 years ago • 3 comments

Describe the bug Searching for repositories and getting the results via the PagedSearchIterable returns a subset of the results with duplicate GHRepository objects and has non-deterministic behavior.

To Reproduce The problem is reproducible with the following JUnit tests.

matchingRepos = github.searchRepositories()
        .user("DanySK")
        .fork(GHFork.PARENT_AND_FORKS)
        .q("Student-Project-OOP")
        .list();
@Test
public void testDuplicates() throws IOException {
    assertEquals(matchingRepos.toList().size(), matchingRepos.toSet().size());
}

@Test
public void testDeterminism() throws IOException {
    var set1 = matchingRepos.toSet();
    var set2 = matchingRepos.toSet();
    assertEquals(set1, set2);
}

Expected behavior The list of GHRepository returned by PagedSearchIterable should contains all the expected results.

Desktop:

  • OS: [MacOS]
  • Browser [firefox]
  • Version [1.308]

tassiluca avatar Aug 25 '22 08:08 tassiluca

The results returned from GitHub are non-deterministic and a subset of possible results. This is by-design behavior documented by GitHub itself. Sorry.

bitwiseman avatar Aug 27 '22 05:08 bitwiseman

Ok, but in this case the isIncomplete() method of PagedSearchIterable should not return true? Instead, it returns false.

tassiluca avatar Aug 30 '22 08:08 tassiluca

Perhaps. You'll need to debug the returned JSON. Perhaps try using the GitHub API via curl and see what comes back.

You could use this library's test facilities to run your commands and record the results. If you submitted a PR showing the failing behavior that would be a huge help.

bitwiseman avatar Aug 31 '22 18:08 bitwiseman