sigmavirus24 / github3.py

Hi, I'm a library for interacting with GItHub's REST API in a convenient and ergonomic way. I work on Python 3.6+.
https://github3.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.21k stars 404 forks source link

github3.exceptions.IncompleteResponse: None The library was expecting more data in the response (KeyError('total')) #1135

Open adosib opened 1 year ago

adosib commented 1 year ago

Getting an github3.exceptions.IncompleteResponse exception when there haven't been any changes in the gist revision.

Should be a quick fix but apparently everything is locked down so I can't issue a PR. Should just be a matter of changing this line from self.total = self.change_status["total"] to self.total = self.change_status.get("total")

Version Information

Minimum Reproducible Example

Can't figure out a way to easily make this reproducible but I've got some gist that in its revision history is not always getting changed and so I get the exception github3.exceptions.IncompleteResponse


>>> import github3
>>> gist_id = "..."
>>> token="..."
>>> gh = github3.login(token=token)
>>> svg = gh.gist(gist_id)
github3.exceptions.IncompleteResponse: None The library was expecting more data in the response (KeyError('total')). Either GitHub modified it's response body, or your token is not properly scoped to retrieve this information.

Exception information

github3.exceptions.IncompleteResponse

offbyone commented 1 year ago

I'm curious what the response was to the call, because total is required by the schema; unlike some keys in there, it's not optional. I think this is actually the right error, and the API sent an invalid response:

          "change_status": {
            "type": "object",
            "properties": {
              "total": {
                "type": "integer"
              },
              "additions": {
                "type": "integer"
              },
              "deletions": {
                "type": "integer"
              }
            }
          },