Skip to content

fix(client): keep the API key out of connection errors - #76

Open
rexsacrorum wants to merge 1 commit into
ZenRows:mainfrom
rexsacrorum:fix/api-key-in-connection-errors
Open

rexsacrorum wants to merge 1 commit into
ZenRows:mainfrom
rexsacrorum:fix/api-key-in-connection-errors

Conversation

@rexsacrorum

Copy link
Copy Markdown

The client sends the key in the apikey query parameter, and a requests connection error names the request URL, so printing or logging it shows the key:

# ZenRowsClient("FAKE_KEY_123"), base URL on a closed local port
requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=2481): Max retries exceeded with url: /v1/?url=https%3A%2F%2Fexample.com&apikey=FAKE_KEY_123 (Caused by NewConnectionError(...))

The client now replaces the key with REDACTED in the messages of the error and of the exceptions it wraps. The exceptions are the same objects, so except requests.ConnectionError and the retries work as before.

The key travels in the apikey query parameter, and a requests connection
error (refused connection, DNS failure, connect timeout) names the request
URL, so printing or logging it showed the key. The client now replaces it
with REDACTED in the messages of the error and of the exceptions it wraps;
the exception objects and their types stay the same.

This branch has not been deployed

No deployments
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.

1 participant