Skip to content

feat: emit structured log events and redact secrets from debug logs - #128

Merged
mogita merged 3 commits into
mainfrom
feat/cha-2957-logging
Jul 22, 2026
Merged

feat: emit structured log events and redact secrets from debug logs#128
mogita merged 3 commits into
mainfrom
feat/cha-2957-logging

Conversation

@mogita

@mogita mogita commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Ticket

https://linear.app/stream/issue/CHA-2957/logging

Summary

Adds structured logging via the existing Logger interface: emits client.initialized, http.request.sent, http.response.received, and http.request.failed events with the standard field schema. Mandatory redaction of api_key/api_secret/token query values and api_secret/token/password body keys. Opt-in WithLogBodies adds (still-redacted) bodies with a one-shot WARN. No-logger behavior unchanged.

Security

Authorization headers and secret query values are no longer logged (they were previously dumped verbatim at DEBUG). The http.request.failed message is scrubbed of any URL-embedded secret.

Tests

Full -short unit suite green; new logging_test.go covers events, redaction, the no-header guarantee, and the transport-error message scrub.

mogita added 3 commits July 22, 2026 13:55
logRequestFailed logged err.Error() verbatim into error.message. Real
*http.Client transport failures wrap the cause in *url.Error, whose
Error() embeds the full request URL including api_key/api_secret/token
query values, leaking secrets on every real transport failure.
Classification still runs on the original err; only the logged message
unwraps *url.Error to its underlying cause.

Also fix http.request.sent logging the caller's params instead of the
built request's actual query, which meant url.query was empty (or
never redacted) for the ~246 of 316 call sites passing nil params.
logRequestSent now takes r.URL.Query() so the mandated redacted
api_key field actually appears in production logs.

Replace the hand-rolled toLowerASCII with strings.ToLower.
@mogita
mogita requested a review from tbarbugli as a code owner July 22, 2026 15:40
@mogita
mogita temporarily deployed to feeds-enabled-shard July 22, 2026 15:40 — with GitHub Actions Inactive
@mogita
mogita temporarily deployed to feeds-enabled-shard July 22, 2026 15:40 — with GitHub Actions Inactive
@mogita
mogita temporarily deployed to feeds-enabled-shard July 22, 2026 15:40 — with GitHub Actions Inactive
@mogita
mogita temporarily deployed to feeds-enabled-shard July 22, 2026 15:40 — with GitHub Actions Inactive
@mogita
mogita temporarily deployed to feeds-enabled-shard July 22, 2026 15:40 — with GitHub Actions Inactive
@mogita
mogita temporarily deployed to feeds-enabled-shard July 22, 2026 15:40 — with GitHub Actions Inactive
@mogita
mogita merged commit 85bffd0 into main Jul 22, 2026
11 checks passed
@mogita
mogita deleted the feat/cha-2957-logging branch July 22, 2026 17:25
This was referenced Jul 24, 2026
This was referenced Aug 12, 2026
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