-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
Fix abc.GitHubAPI.graphql() to accept response content types lacking spaces #122
Fix abc.GitHubAPI.graphql() to accept response content types lacking spaces #122
Conversation
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.
Looking good, but I think some error conditions should raise and another case where it shouldn't. 😄
Co-authored-by: Brett Cannon <brett@python.org>
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.
Getting down to formatting, so almost there!
gidgethub/abc.py
Outdated
if not response_data: | ||
raise GraphQLException("Response contained no data", response_data) |
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.
Maybe move this up as it's a bigger issue than trying to get the content-type.
Co-authored-by: Brett Cannon <brett@python.org>
@brettcannon Looks like Looks like it changed from 0.13.1: https://github.com/encode/httpx/blob/ebc9c2936503cbff979658a70530ce22775bd11a/httpx/_types.py#L40 |
What I don't get is why is The two options I can think of are:
I don't love either, but I will accept either as well. |
I'm going to go with an ignore I think because as they make clear in their readme, the library is still in development and the types could very well change again. |
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.
I just realized there are no docs for the new exception. Last thing and then I can merge this.
Good call. I missed that. |
Thanks for all the work, @caseyduquettesc ! |
@brettcannon coincidentally |
Ah, that's why it's suddenly failing! 👍 |
Background
Closes #121
As stated in the issue, Github enterprise server sets a response header equal to
application/json;charset=utf-8
(note: without the space separating the type and character encoding).The graphql method in the ABC asserts the content type header equals
application/json; charset=utf-8
(note: with space).The failing assertion prevents the method from successfully returning.
Change
sansio
to parse the content-type from the header and load the json based on that.sansio._decode_body()
but it did have a little bit of v3 specific logic in there. Maybe a_decode_gql_body()
is needed?GraphQLResponseTypeError
.Test Plan
Added three tests to prevent regressions and test the new exception. I appended the original issue number just in case anyone is curious about the context of the tests. If that's not your style, I can remove it.
test_response_content_type_parsing_gh121
test_unknown_response_content_type_gh121
test_no_response_content_type_gh121