octokit.net
octokit.net copied to clipboard
Validation Exception while searching for Repos within an Organization
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 Can you confirm if the resources exist and you have adequate permission to view (as it suggests in the error message)?
@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.
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:, ororg: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
👋 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!