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

Validation Exception while searching for Repos within an Organization

Open anphyj opened this issue 5 years ago • 3 comments

Hi, I am using the Octokit .Net library to search for repos within an Organization. When I have the organization filter, I get the below exception.

{"message":"Validation Failed","errors":[{"message":"The listed users and repositories cannot be searched either because the resources do not exist or you do not have permission to view them.","resource":"Search","field":"q","code":"invalid"}],"documentation_url":"https://docs.github.com/v3/search/"}

Sample Code

    var repoSearch = await client.Search.SearchRepo(
                        new SearchRepositoriesRequest(
                          $"{"q=test+org:{orgName}"}")
                        {
                           
                        });

When I remove the orgfilter, it works fine

anphyj avatar Nov 20 '20 03:11 anphyj

@anphyj Can you confirm if the resources exist and you have adequate permission to view (as it suggests in the error message)?

ranjjose-chaz avatar Nov 26 '20 09:11 ranjjose-chaz

@ranjjose-chaz the repository which I am trying to search exist. It also gets listed when I use the library to get all the repos for the organization ("client.Repository.GetAllForOrg"). However when I try to search it gives the error.

anphyj avatar Nov 26 '20 09:11 anphyj

This feels like a known limitation of search from the docs: https://docs.github.com/en/rest/reference/search#access-errors-or-missing-search-results

You need to successfully authenticate and have access to the repositories in your search queries, otherwise, you'll see a 422 Unprocessible Entry error with a "Validation Failed" message. For example, your search will fail if your query includes repo:, user:, or org: qualifiers that request resources that you don't have access to when you sign in on GitHub.

Not really sure what I can do here, as we're just wrapping the GitHub API. This might be a question better asked over on the GitHub Community forum: https://github.community/c/github-ecosystem/37

shiftkey avatar Feb 25 '21 18:02 shiftkey

👋 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 25 '23 02:07 github-actions[bot]