Skip to content
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

fixed uncontrolled error when server responds 200 #4317

Merged

Conversation

memsharded
Copy link
Member

Changelog: Fix: Improve error message when a server (like a proxy), returns 200-OK for a conan api call, but with an unexpected message.
Docs: Omit

Close #3985

@ghost ghost assigned memsharded Jan 15, 2019
@ghost ghost added the stage: review label Jan 15, 2019
@memsharded memsharded added this to the 1.12 milestone Jan 15, 2019
@memsharded memsharded assigned lasote and unassigned memsharded Jan 15, 2019
@ghost ghost assigned memsharded Jan 16, 2019
result = json.loads(decode_text(response.content))
try: # This can fail, if some proxy returns 200 and an html message
result = json.loads(decode_text(response.content))
except Exception:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is produced because of a message that it is not a json, right? The right way to check this is to check if application/json header is present. I know you would think that is risky, but a server returning a json without a json header is a bug. The protocols need to be followed. If our own test's with the server fails (I hope they don't) we need to fix it in the server but I agree we cannot break old servers, in that case, narrow the exception capturing to the json decoding, please.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need also to test with Artifactory.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.
Tested manually with Artifactory CE 6.3 and Bintray

Copy link
Contributor

@lasote lasote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@memsharded memsharded merged commit 302deba into conan-io:develop Jan 17, 2019
@ghost ghost removed the stage: review label Jan 17, 2019
@memsharded memsharded deleted the feature/fix_server_unexpected_200 branch January 17, 2019 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants