github3.exceptions.UnprocessableResponseBody when branch doesn't exist but a similar name one does
I tend to use repo.branch() to check if a branch exists, I encountered this very specific issue while testing.
Version Information
- Python version: 3.7.1
- Pip version: 19.0.1
- github3.py: 1.0.0a4, requests: 2.18.4, uritemplate.py: 3.0.2
Minimum Reproducible Example
- Create a branch named
1.x-testand push it to the repository - call repo.branch("1.x") (starts with the same prefix)
Call will fail because the github api returns an array - https://developer.github.com/v3/git/refs
Exception information
File "/usr/lib/python3.7/site-packages/github3/repos/repo.py", line 1835, in ref
return self._instance_or_null(Reference, json)
File "/usr/lib/python3.7/site-packages/github3/models.py", line 197, in _instance_or_null
"GitHub's API returned a body that could not be handled", json
github3.exceptions.UnprocessableResponseBody: GitHub's API returned a body that could not be handled
Hi there @pmatias
Thanks for filing this issue. You've taught me something new about the API today. This is new API behaviour since the logic in github3.py was implemented. It seems we'll need to handle this better going forward.
As a side note, github3.py 1.0 is out of alpha now and (if I remember correctly) the latest version is 1.3.0. It'd be good to hear, (separate from this issue) if there are issues keeping you on a1.0.0a4 though.
Thanks for the quick reply @sigmavirus24 !
I've created a mildly big CI framework for the company I work for that depends on several libraries, this one being one of them. Last time I've tried to just upgrade I've encountered several compatibility issues (on my side of the code) here and there that I'll address in the future, I just haven't had the time to do it yet :)