Stop logging the Census API key in geoinfo_from_params - #8
Merged
Merged
Conversation
The request parameters were logged at INFO after the key was added, so every geoinfo request wrote the key into notebook outputs. Log them before adding the key. Part of #7. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #7.
Change
geoinfo_from_params()logged its request parameters at INFO after addingkey, so every geoinfo request wrote the Census API key into logs, and from there into notebook outputs. The hierarchical geography lookup calls it once per place or county subdivision, which meant hundreds of copies perCensusAPIcall. The log statement now runs before the key is added. The key is still sent with the request.That was the only morpc-census log statement containing the key. The other places that add the key pass it to
morpc.reqfunctions (get_json_safely,get_text_safely), which redact it in their own logs and errors from morpc 0.7.5 (morpc/morpc-py#207). Until then, morpc's DEBUG logs and failed-request messages can still include it.Testing
test_geoinfo_from_params_does_not_log_the_api_keychecks that the key is passed to the request but absent from captured logs at DEBUG level. It failed before the change.Still open in #7
doc/02-morpc-census-demo.ipynb, which still contain the key.🤖 Generated with Claude Code