octokit.net icon indicating copy to clipboard operation
octokit.net copied to clipboard

Construction of ReadOnlyCollection in RepositoriesClient.GetAllLanguages() method can throw null argument exception

Open aaronhoffman opened this issue 9 years ago • 2 comments

see here: https://github.com/octokit/octokit.net/blob/master/Octokit/Clients/RepositoriesClient.cs#L792

If this method is called and the API does not return a value, a null argument exception is thrown by the ReadOnlyCollection constructor.

example repo: vhf/free-programming-books (id: 13491895)

Note: I'd like to contribute by opening a PR for this issue. I first need to investigate how "empty" results from the API are handled by other methods.

aaronhoffman avatar Sep 13 '16 21:09 aaronhoffman

This seems plausible according to the reference source, but I'm not sure why this code shouldn't return an empty enumerable when there are no values in the response:

data.Select(kvp => new RepositoryLanguage(kvp.Key, kvp.Value)).ToList()

shiftkey avatar Sep 13 '16 22:09 shiftkey

I'll need to double check. I believe that was the exception and stack trace I was seeing, but I agree that the .ToList() should not return null.

aaronhoffman avatar Sep 14 '16 13:09 aaronhoffman

👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!

github-actions[bot] avatar Jul 28 '23 01:07 github-actions[bot]