github3.py
github3.py copied to clipboard
Organization._api uses faulty URL
Some requests like /repo/:owner/:repo
return a users URL for an organization causing further use of the model Organization to act as a user. Requests like Organization.teams
built on top of that faulty url causing the url /users/:user/teams
which does not exist, it should be /orgs/:org/teams
.
Example of what is returned for /repos/:owner/:repo
:
{
"organization": {
"login": "octocat",
"id": 1,
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
// It shows /users/octocat, but we need /orgs/octocat for getting its teams.
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "Organization",
"site_admin": false
}
// There is more here, this is just the important part
}
This string is set in BaseAccount. In my opinion this is an error in the GitHub API itself because it clearly states the dictionary value is an organization even though it uses user endpoints. It might be worth making an issue for the GitHub API. Currently I would set the _api
field in code for the User
and Organization
models.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
So this is absolutely, IMO, something that should be reported to [email protected]
. If you can send them an email and CC me, that would be wonderful. We rely on their information to be correct for most things and when that fails, we try our best to not munge their values into correctness unless we absolutely have to.
The e-mail has been sent, we'll see what their opinion is.
So based on the (unsurprisingly) unhelpful conversation with GitHub support, it looks like we should move away from trusting any URLs that the GitHub returns to us and start constructing everything from scratch. 😢