-
Notifications
You must be signed in to change notification settings - Fork 407
Fix gist.history keyerrors #1020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/github3/gists/history.py
Outdated
self.change_status = history.get("change_status") | ||
self.additions = self.change_status.get("additions") | ||
self.deletions = self.change_status.get("deletions") | ||
self.total = self.change_status.get("total") | ||
self.committed_at = self._strptime(history.get("committed_at")) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This now makes it indistinguishable between GitHub returning null
and the key being missing which semantically are two very different things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get()
should be added then only to additions and deletions right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So missing data makes me think there's a way that GitHub represents the data that is different than the object we have here. (Think about ShortUser versus User versus AuthenticatedUser. There's different representations of the same object with different data. The history object here seems to have another representation. It seems like this happens when retrieving a single gist
by its id (in the original issue). Given that used to work, that means GitHub's changed something and we probably need a different representation here (sadly).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I'd love some kind of NotProvided
singleton rather than this many objects but that proved confusing in the past
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sigmavirus24 I rolled back that changes for unnecessary fields. I am not really sure how to reproduce this other object representation and I don't have much knowledge of Github Gists. Could we use this PR as a hotfix to solve the user's problem and then we dig into this new structure in a new issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sigmavirus24 also the user (on #1019) printed self.change_status before the error, the it is not quite another representation:
{'total': 2, 'additions': 1, 'deletions': 1}
{'total': 1, 'additions': 1, 'deletions': 0}
{'total': 4, 'additions': 2, 'deletions': 2}
{'total': 2, 'additions': 1, 'deletions': 1}
{'total': 1, 'additions': 1, 'deletions': 0}
{'total': 2, 'additions': 1, 'deletions': 1}
{'total': 3, 'additions': 2, 'deletions': 1}
{'total': 1, 'additions': 1, 'deletions': 0}
{'total': 4, 'additions': 2, 'deletions': 2}
{'total': 1, 'additions': 1, 'deletions': 0}
{}
Closes #1019