feat(telemetry): include sanitized error message in events#3
feat(telemetry): include sanitized error message in events#3facundofarias merged 1 commit intomainfrom
Conversation
Telemetry currently reports exit_code and a coarse error_class bucket but
discards the actual error string, leaving us unable to diagnose the
"internal" cluster (e.g. 6 of 15 auth login attempts failed with class
"internal" over the last 30d, root cause unknown from analytics alone).
Add an ErrorMessage property to cli_command events:
- first line of err.Error() only
- home dir replaced with ~
- emails, UUIDs, bearer tokens, and api_key=/token=/secret=/password=
style values redacted
- truncated to 200 chars
The privacy doc in 'dhq telemetry' is updated to reflect the new field.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
Disabled knowledge base sources:
WalkthroughThe changes extend telemetry event tracking by adding a sanitized error message field to the Changes
Sequence Diagram(s)sequenceDiagram
participant Command as Command Execution
participant Error as Error Capture
participant Sanitizer as SanitizeErrorMessage
participant Event as telemetry.Event
participant Tracker as Mixpanel Tracker
Error->>Sanitizer: Pass error object
Sanitizer->>Sanitizer: Extract first line
Sanitizer->>Sanitizer: Redact credentials, UUIDs, emails
Sanitizer->>Sanitizer: Replace home paths with ~
Sanitizer->>Sanitizer: Truncate to max length
Sanitizer-->>Event: Return sanitized string
Command->>Event: Populate ErrorMessage field
Event->>Tracker: Send Event with ErrorMessage
Tracker->>Tracker: Emit error_message to Mixpanel
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ff9bfdbd42
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // bearerRE catches "Bearer <token>" and "Authorization: Bearer <token>" patterns. | ||
| bearerRE = regexp.MustCompile(`(?i)(bearer\s+)[A-Za-z0-9._\-]{8,}`) | ||
| // kvSecretRE catches key=value / token=value style leaks (api_key=..., secret=..., token=...). | ||
| kvSecretRE = regexp.MustCompile(`(?i)\b(api[_-]?key|api[_-]?token|secret|token|password|passwd)\s*[=:]\s*\S+`) |
There was a problem hiding this comment.
Redact access_token-style secrets in telemetry sanitizer
SanitizeErrorMessage is intended to prevent credential leakage, but kvSecretRE only matches token when it appears as a standalone key, so values like access_token=... or id_token=... pass through unredacted. Because many OAuth/API errors include those exact keys, telemetry can still emit live tokens in error_message when such errors are reported. Expanding the key pattern (or matching token-like suffixes) would close this leak.
Useful? React with 👍 / 👎.
Summary
error_messageproperty tocli_commandMixpanel events~, emails / UUIDs / bearer tokens /key=valuesecrets redacted, truncated to 200 charsdhq telemetrylong help to reflect the new fieldWhy
Today telemetry reports
exit_codeand a coarseerror_classbucket but discards the actual error string. That makes theinternalcluster opaque — Mixpanel currently shows 6 of 15auth loginattempts in the last 30d failing witherror_class=internal, root cause unknown from analytics alone. With a sanitized first-line message we can finally see whether those are network timeouts, keyring failures, malformed responses, etc., without leaking PII.Privacy
err.Error()only — no stack traces~Bearer <token>, andapi_key=/token=/secret=/password=style key-value leaksDEPLOYHQ_NO_TELEMETRY=1ordhq telemetry disableTest plan
go test ./...— greengo vet ./...— cleangolangci-lint run(latest) — 0 issueserror_messagelands on a deliberately failed invocation (e.g. `dhq deployments show non-existent`)🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Documentation