Skip to content

Stop logging the Census API key in geoinfo_from_params - #8

Merged
jinskeep-morpc merged 1 commit into
mainfrom
fix/redact-api-key
Sep 24, 2026
Merged

jinskeep-morpc merged 1 commit into
mainfrom
fix/redact-api-key

Conversation

@jinskeep-morpc

Copy link
Copy Markdown
Collaborator

Part of #7.

Change

geoinfo_from_params() logged its request parameters at INFO after adding key, 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 per CensusAPI call. 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.req functions (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

  • New test: test_geoinfo_from_params_does_not_log_the_api_key checks that the key is passed to the request but absent from captured logs at DEBUG level. It failed before the change.
  • Full suite: 344 passed.

Still open in #7

  • Clearing the committed outputs of doc/02-morpc-census-demo.ipynb, which still contain the key.
  • Rotating the key.

🤖 Generated with Claude Code

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>
@jinskeep-morpc
jinskeep-morpc merged commit 36bbc92 into main Sep 24, 2026
5 of 7 checks passed
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