You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that gidgethub is not able to handle a part of the 422 response. This happened when the app tried to make a review comment on a line that was not part of the pull request diff. I didn't know that was not possible but this mistake revealed this bug in the code.
{
"message": "Unprocessable Entity",
"errors": [
"Line must be part of the diff"
],
"documentation_url": "https://docs.github.com/rest/reference/pulls#create-a-review-for-a-pull-request",
}
The code that triggered the error, taken from gidgethub.sansio.decipher_response:
exc_type=InvalidFieldiferrors:
ifany(
------>e["code"]
in ["missing", "missing_field", "invalid", "already_exists"]
foreinerrors
):
error_context=", ".join(repr(e.get("field")) foreinerrors)
message=f"{message} for {error_context}"
Logged traceback:
2020-12-10T14:57:43.757626+00:00 app[web.1]: await gh.post(
2020-12-10T14:57:43.757626+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gidgethub/abc.py", line 175, in post
2020-12-10T14:57:43.757626+00:00 app[web.1]: data, _ = await self._make_request(
2020-12-10T14:57:43.757626+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gidgethub/abc.py", line 114, in _make_request
2020-12-10T14:57:43.757627+00:00 app[web.1]: data, self.rate_limit, more = sansio.decipher_response(*response)
2020-12-10T14:57:43.757627+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gidgethub/sansio.py", line 340, in decipher_response
2020-12-10T14:57:43.757628+00:00 app[web.1]: if any(
2020-12-10T14:57:43.757628+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gidgethub/sansio.py", line 341, in <genexpr>
2020-12-10T14:57:43.757628+00:00 app[web.1]: e["code"]
2020-12-10T14:57:43.757628+00:00 app[web.1]: TypeError: string indices must be integers
The text was updated successfully, but these errors were encountered:
A quick fix would be to check whether the key code exists in the errors object, otherwise accumulate whatever is in the errors object and combine it with the message:
It seems that
gidgethub
is not able to handle a part of the 422 response. This happened when the app tried to make a review comment on a line that was not part of the pull request diff. I didn't know that was not possible but this mistake revealed this bug in the code.The code that triggered the error, taken from
gidgethub.sansio.decipher_response
:Logged traceback:
The text was updated successfully, but these errors were encountered: