feat(telemetry): report unknown commands to Sentry#563
Merged
Conversation
Contributor
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Dashboard
Other
Bug Fixes 🐛Dashboard
Other
Internal Changes 🔧Coverage
Other
🤖 This preview updates automatically when you update the PR. |
Contributor
Codecov Results 📊✅ 126 passed | Total: 126 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 1271 uncovered lines. Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 95.40% 95.40% —%
==========================================
Files 194 194 —
Lines 27655 27655 —
Branches 0 0 —
==========================================
+ Hits 26384 26384 —
- Misses 1271 1271 —
- Partials 0 0 —Generated by Codecov Action |
53b77a2 to
26807a5
Compare
26807a5 to
448f031
Compare
When Stricli's route scanner rejects an unrecognized subcommand (e.g., `sentry issue helpp`) it handles the error internally — writing to stderr and setting exitCode to 251 without throwing. This means the error was invisible to Sentry telemetry. Add `reportUnknownCommand()` inside `runCommand` (within the `withTelemetry` scope) that detects `ExitCode.UnknownCommand` after `run()` completes and reports via `Sentry.captureMessage()` with: - `command` tag set to `"unknown"` for filtering - `sentry.org` tag from default organization (SQLite, no API call) - `unknown_command` context with full argv, the unknown token, fuzzy suggestions from the introspection system, and default org - User context (already set by `initTelemetryContext` in the `withTelemetry` scope)
c2d30ca to
3e70280
Compare
3e70280 to
5ecbd27
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
…sitive argv Address two Bugbot findings: 1. High: reportUnknownCommand performs dynamic imports, route resolution, and SQLite reads without error handling. Exceptions would propagate through withTelemetry's catch block, marking the session as crashed and overriding the UnknownCommand exit code. Fix: wrap the call in try/catch so telemetry failures are silently ignored. 2. Medium: raw argv was sent to Sentry context without redacting --token values. Add redactArgv() that replaces values following sensitive flags (--token, --auth-token) with [REDACTED] in both --flag=value and --flag <value> forms. Uses SENSITIVE_ARGV_FLAGS set mirroring SENSITIVE_FLAGS from telemetry.ts. Extracted sensitiveArgvFlag() helper to stay under Biome's cognitive complexity limit of 15.
5ecbd27 to
33dd92d
Compare
5 tasks
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.

When Stricli's route scanner rejects an unrecognized subcommand (e.g.,
sentry issue helpp), it handles the error internally — writing to stderrand setting exitCode to 251 (UnknownCommand) without throwing. This means
the error was invisible to Sentry telemetry.
Adds
reportUnknownCommand()insiderunCommand(within thewithTelemetryscope) that detects
ExitCode.UnknownCommandafterrun()completes andreports via
Sentry.captureMessage()with rich context:initTelemetryContext()in thewithTelemetryscope — user ID, email, instance ID, runtime, etc.resolveCommandPath()from the introspectionsystem to find the unknown token and fuzzy-matched alternatives
This covers nested route typos like
sentry issue helpporsentry dashboard creat. Top-level typos likesentry isseu listarerouted through the help command's fuzzy matching via
defaultCommand: "help".Changes
src/bin.ts: ImportExitCode, addreportUnknownCommand()thatdetects unknown command exit code, walks the route tree for fuzzy
suggestions, reads default org from SQLite, and captures a Sentry
message event with structured context.