HTTP Error 422: Unprocessable Entity when using paged with client.search.code
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
Research direction
Reproduce the sample using client.search.code and paged, then inspect ghapi/page.py and ghapi/core.py around pagination and request construction. Check the GitHub code-search request constraints to identify why the paged call returns HTTP 422; done means the example paginates successfully and has a regression test for the failing case.
Written by the indexing model from the issue text.
Description
Hey all I am getting the following when running code like the sample I have provided:
import os
from ghapi.all import GhApi
from ghapi.page import paged
from dotenv import load_dotenv
GH_TOKEN = os.getenv('GH_TOKEN', None)
def get_client() -> GhApi:
"""Return the GitHub Client"""
return GhApi(token=GH_TOKEN)
def search_results(query: str, client: GhApi):
"""Yeilds results pages"""
search_gen = paged(client.search.code, per_page=100, q=query)
for results in search_gen:
yield results
for result in search_results("filename:.dockercfg auth repo:dtaivpp/NewsTicker", get_client()):
print(result)
Running the above brings me to the following:
Traceback (most recent call last):
File "gh-dorker/dorker.py", line 83, in
main(dorks=args.dorks, search=args.search, scope=args.scope)
File "gh-dorker/dorker.py", line 43, in main
for result in search_results(query, client):
File "gh-dorker/dorker.py", line 24, in search_results
for results in search_gen:
File "/Users/dtippett/Desktop/Software_Projects/gh-dorker/venv/lib/python3.8/site-packages/ghapi/page.py", line 16, in paged
yield from itertools.takewhile(noop, (oper(*args, per_page=per_page, page=i, **kwargs) for i in range(1,max_pages+1)))
File "/Users/dtippett/Desktop/Software_Projects/gh-dorker/venv/lib/python3.8/site-packages/ghapi/page.py", line 16, in
yield from itertools.takewhile(noop, (oper(*args, per_page=per_page, page=i, **kwargs) for i in range(1,max_pages+1)))
File "/Users/dtippett/Desktop/Software_Projects/gh-dorker/venv/lib/python3.8/site-packages/ghapi/core.py", line 63, in call
return self.client(self.path, self.verb, headers=headers, route=route_p, query=query_p, data=data_p)
File "/Users/dtippett/Desktop/Software_Projects/gh-dorker/venv/lib/python3.8/site-packages/ghapi/core.py", line 108, in call
res,self.recv_hdrs = urlsend(path, verb, headers=headers or None, debug=self.debug, return_headers=True,
File "/Users/dtippett/Desktop/Software_Projects/gh-dorker/venv/lib/python3.8/site-packages/fastcore/net.py", line 212, in urlsend
return urlread(req, return_json=return_json, return_headers=return_headers)
File "/Users/dtippett/Desktop/Software_Projects/gh-dorker/venv/lib/python3.8/site-packages/fastcore/net.py", line 113, in urlread
if 400 <= e.code < 500: raise ExceptionsHTTP[e.code](e.url, e.hdrs, e.fp) from None
fastcore.basics.HTTP422UnprocessableEntityError: HTTP Error 422: Unprocessable Entity
- Dominant language
- Python
- Stars
- 687
- Forks
- 69
- Avg merge
- 1m
- Merged PRs (30d)
- 2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from AnswerDotAI/ghapi
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
AnswerDotAI/ghapi#158 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
AnswerDotAI/ghapi#120 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 58/100
AnswerDotAI/ghapi#208 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
AnswerDotAI/ghapi#201 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
AnswerDotAI/ghapi#186 ·
All issues in AnswerDotAI/ghapi
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
syfoud/Simulated_Scepter#172 ·
-
A cancelled tests run makes the coverage comment workflow fail and reports it as a red check on main Openarea: ci bug perceived difficulty: 3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Nitjsefnie-Harness-Commons/daedalus#921 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
EleutherAI/lm-evaluation-harness#4207 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ClickHouse/clickhouse-connect#1057 ·