Navigation Menu

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

Parse raw_data on error only if the Content-Type is application/json. #91

Merged
merged 6 commits into from Dec 22, 2021
Merged

Parse raw_data on error only if the Content-Type is application/json. #91

merged 6 commits into from Dec 22, 2021

Conversation

mccullocht
Copy link
Contributor

@mccullocht mccullocht commented Nov 16, 2021

Description

Some opensearch REST APIs will return a Content-Type of text/plain for certain
status codes which will trigger logging when the response is not parsable as
json. Checking the content-type first avoids this error.

This frequently happens with 401s, which occurs when we rotate user keys.
The input that triggers this behavior can be triggered with curl:

$  curl -k -u"admin:wrong" -w"\n%{http_code}\n%{content_type}\n" https://localhost:9200/_cluster/health
Unauthorized
401
text/plain; charset=UTF-8

Issues Resolved

#92

Check List

  • Commits are signed per the DCO using --signoff

Signed-off-by: Trevor McCulloch trevor.mcculloch@benchling.com

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link
Collaborator

@axeoman axeoman left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution and apologies for the delay.
Overall looks good, could you please fix the formatting by running black locally and sign the commits.
Also, rebase on fresh main will help with passing integration tests.

Trevor McCulloch added 3 commits December 20, 2021 13:14
Some opensearch REST APIs will return a Content-Type of text/plain for certain
status codes which will trigger logging when the response is not parsable as
json. Checking the content-type first avoids this error.

This frequently happens with 401s, which occurs when we rotate user keys.
The input that triggers this behavior can be triggered with `curl`:

```
$  curl -k -u"admin:wrong" -w"\n%{http_code}\n%{content_type}\n" https://localhost:9200/_cluster/health
Unauthorized
401
text/plain; charset=UTF-8
```

Signed-off-by: Trevor McCulloch <trevor.mcculloch@benchling.com>
Signed-off-by: Trevor McCulloch <trevor.mcculloch@benchling.com>
Signed-off-by: Trevor McCulloch <trevor.mcculloch@benchling.com>
@mccullocht
Copy link
Contributor Author

Rebased and signed the commits. Fixed formatting error http_urllib3.py. PTAL

Trevor McCulloch added 3 commits December 21, 2021 09:41
Signed-off-by: Trevor McCulloch <trevor.mcculloch@benchling.com>
Signed-off-by: Trevor McCulloch <trevor.mcculloch@benchling.com>
Signed-off-by: Trevor McCulloch <trevor.mcculloch@benchling.com>
@axeoman axeoman merged commit 1cd15b0 into opensearch-project:main Dec 22, 2021
@mccullocht mccullocht deleted the mccullocht-401-no-log branch December 22, 2021 20:20
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

3 participants