VINAY NAIR
VINAY NAIR

Reputation: 41

Github API incomplete_results for a simple search

I am querying github via API. This is a really simple query to find files called pipelines.yaml in pipelines folder in my org abc-xyz.

Querying https://api.github.com/search/code?q=filename:pipelines+path:pipelines+language:yaml+org:abc-xyz

However, all my outputs have a "incomplete_results:true". The output length varies every time I query by a repo or two.

Query Output:[total_count:16, incomplete_results:true, items:[[name:pipelines.yaml, path:pipelines/pipelines.yaml.

How do I fix this. I understand why github does this, but I see online large results causing this problem. But in my case I am talking of less than 500 results. Ideally less than 50. However,my org has about 800 repos. Is this why I always get an incomplete_results. Is there an easy way to fix this? Appreciate any feedback possible. My repo is private. Thanks Vinay

Upvotes: 3

Views: 2109

Answers (1)

Brendan Forster
Brendan Forster

Reputation: 2718

There's some details in the documentation that are helpful here:

To keep the Search API fast for everyone, we limit how long any individual query can run. For queries that exceed the time limit, the API returns the matches that were already found prior to the timeout, and the response has the incomplete_results property set to true.

Reaching a timeout does not necessarily mean that search results are incomplete. More results might have been found, but also might not.

My guess here is that the query is hitting a timeout and returning what it could find at that time. Tuning the search query using the advice also in the docs might help to get your query under that timeout. Perhaps moving to querying per-repository and doing client-side caching of results here might work, but that might also cause you to need to think about rate limiting.

Upvotes: 3

Related Questions