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 402 forks source link

latest_release throws exception #1105

Open mwoehlke-kitware opened 2 years ago

mwoehlke-kitware commented 2 years ago

latest_release() is dying with:

  File ".../src/github3/repos/repo.py", line 2163, in latest_release
    return self._instance_or_null(release.Release, json)
  File ".../src/github3/models.py", line 152, in _instance_or_null
    return instance_class(json, self)
  File ".../src/github3/models.py", line 53, in __init__
    self._update_attributes(json)
  File ".../src/github3/repos/release.py", line 102, in _update_attributes
    self.author = users.ShortUser(release["author"], self)
  File ".../src/github3/models.py", line 53, in __init__
    self._update_attributes(json)
  File ".../src/github3/users.py", line 309, in _update_attributes
    self.avatar_url = user["avatar_url"]
TypeError: 'NoneType' object is not subscriptable

This happens on https://api.github.com/repos/uNetworking/uSockets/releases/latest, which, as of reporting, is https://api.github.com/repos/uNetworking/uSockets/releases/tags/v0.8.1, which are producing "author": null rather than "author": {...}.

This looks to be similar to #988.

sigmavirus24 commented 2 years ago

Can you include version information about github3.py, it's dependencies, and the version of Python you're using? We can definitely fix this, I just want to make sure it's definitely a bug in the latest version

mwoehlke-kitware commented 2 years ago

I did the following:

$ docker run --rm -it ubuntu:jammy
# apt update && apt install -y python3-pip
# pip3 install github3.py
# python3
>>> gh = github3.GitHub()
>>> repo = gh.repository('uNetworking','uSockets')
>>> repo.latest_release()

This reproduces the issue. It should also be trivial to reproduce this environment to get whatever version information you want; however, AFAICT, the relevant code hasn't changed and this should be just as trivially reproducible on master. Basically, _User._update_attributes expects to get a JSON object, but gets None because of the "author": null that is sent in the reply.