Skip to content

[http_client] remove requests exception contexts#266

Merged
yannmh merged 1 commit intomasterfrom
yann/rm-api-key-logs
May 2, 2018
Merged

[http_client] remove requests exception contexts#266
yannmh merged 1 commit intomasterfrom
yann/rm-api-key-logs

Conversation

@yannmh
Copy link
Copy Markdown

@yannmh yannmh commented May 1, 2018

On Python 3, remove requests exception contexts before raise a new exception to avoid
accidentally leaking URLs and credentials (API and application keys).

Traceback (most recent call last): 
File "/usr/local/lib/python3.6/site-packages/datadog/api/http_client.py", line 73, in request 
result.raise_for_status() 
File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 935, in raise_for_status 
raise HTTPError(http_error_msg, response=self) 
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://app.datadoghq.com/api/v1/downtime?api_key=<redacted>&application_key=<redacted>

During handling of the above exception, another exception occurred:

Traceback (most recent call last): 
[...]
File "/usr/local/lib/python3.6/site-packages/datadog/api/resources.py", line 147, in get_all 
return APIClient.submit('GET', cls._class_url, **params) 
File "/usr/local/lib/python3.6/site-packages/datadog/api/api_client.py", line 129, in submit 
proxies=_proxies, verify=_cacert 
File "/usr/local/lib/python3.6/site-packages/datadog/api/http_client.py", line 84, in request 
raise HTTPError(e.response.status_code, result.reason) 
datadog.api.exceptions.HTTPError: Datadog returned a bad HTTP response code: 500 - Internal Server Error. Please try again later. If the problem persists, please contact support@datadoghq.com" 

On Python 3, remove `requests` exception contexts before raise a new exception to avoid
accidentally leaking URLs and credentials (API and application keys).
@yannmh yannmh self-assigned this May 1, 2018
Copy link
Copy Markdown
Contributor

@nmuesch nmuesch left a comment

Choose a reason for hiding this comment

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

Hey, thanks for taking care of this! I'm wondering if down the line we want to come up with a more universal scrubber for a more generic set of cases. But this looks like it will get the job done 🎉

@yannmh yannmh merged commit fa4cc0c into master May 2, 2018
@yannmh yannmh deleted the yann/rm-api-key-logs branch May 2, 2018 19:53
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.

2 participants