repos.update_branch_protection - Error 422: Unprocessable Entity
jangroth opened this issue · 1 comments
jangroth commented
I'm getting the above error when setting up branch protection. I believe this might be a ghapi
issue, as I can invoke the native API with the exact same values without problems.
Call:
result = self.api.repos.update_branch_protection(
owner=self.org_name,
repo=repo_name,
branch=branch_name,
required_status_checks={"strict": True, "contexts": ["check-pull-requests"]},
enforce_admins=None,
required_pull_request_reviews={
"dismissal_restrictions": {},
"dismiss_stale_reviews": False,
"require_code_owner_reviews": require_code_owner_reviews,
"required_approving_review_count": 1,
"bypass_pull_request_allowances": {},
},
restrictions=None,
)
Error:
File "C:\Users\grojan\projects\ffma-itan-dev_portal\ffma_dev_portal\github.py", line 196, in setup_branch_protection
restrictions=None,
File "c:\Users\grojan\projects\ffma-itan-dev_portal\.venv\lib\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 "c:\Users\grojan\projects\ffma-itan-dev_portal\.venv\lib\site-packages\ghapi\core.py", line 113, in __call__
route=route or None, query=query or None, data=data or None)
File "c:\Users\grojan\projects\ffma-itan-dev_portal\.venv\lib\site-packages\fastcore\net.py", line 212, in urlsend
return urlread(req, return_json=return_json, return_headers=return_headers)
File "c:\Users\grojan\projects\ffma-itan-dev_portal\.venv\lib\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
The same call against the native API goes through without problems
self.invoke_native_api(
method="PUT",
url=f"https://api.github.com/repos/{self.org_name}/{repo_name}/branches/{branch_name}/protection",
payload={
"required_status_checks": {
"strict": True,
"contexts":["check-pull-requests"]
},
"enforce_admins": None,
"required_pull_request_reviews": {
"dismissal_restrictions": {},
"dismiss_stale_reviews": False,
"require_code_owner_reviews": require_code_owner_reviews,
"required_approving_review_count": 1,
"bypass_pull_request_allowances": {}
},
"restrictions": None
}
)
(invoke_native_api
is a thin wrapper around requests
)
jangroth commented
Closing the issue as I am not using the latest version (1.0.0 instead of 1.0.3)