gidgethub / gidgethub

An async GitHub API library for Python

Home Page:https://gidgethub.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Recover status code after request

GuillemBarroso opened this issue Β· comments

Hi!

I am using gidgethub to create a bot within a GitHub App. I am struggling when checking whether a user is member of a certain organization, see GitHub documentation for this call.

From what I understood, gh.getitem only returns the body of the request. However, the call mentioned above only returns a status code as a response (either 204, 302 or 404). Thus, I am not sure how to recover this status code after using await gh.getitem(url, oauth_token=oauth_token).

Please, let me know if I am misunderstanding something. Thanks!

Unfortunately, when I designed the API, I either didn't know about that part of the API or it didn't exist yet. πŸ˜… I would be okay with adding a getstatus() API endpoint in gidgethub.abc. It could probably be done by refactoring the details in _make_request() that build everything together to pass to _request() and then calling _request() directly.

Thank you for the quick response. I might have found a workaround by listing all the members of an organization, a request that does provide a body as a response. However, I'm not too sure what approach would be the best for my case. I'll keep assessing both options. Thanks!

@brettcannon out of curiosity what would be your thought about augmenting _make_request() to return the status code? It's an internal method, by the naming, and the call sites already often ignore one of the return values.

out of curiosity what would be your thought about augmenting _make_request() to return the status code?

Without seeing how it makes the code look I don't have a specific opinion either way.

Coincidentally, there's this pull request right over there πŸ‘‰ ;)

Coincidentally, there's this pull request right over there πŸ‘‰ ;)

Oh, I know, but I'm still digging myself out from all of my GitHub notifications, so I'm treating everything in isolation in case it takes a while to get to your PR. 😁