fix(cli): stop reporting expected channel currentBundle failures as exceptions - #2886
Draft
posthog-eu[bot] wants to merge 1 commit into
Draft
Conversation
…xceptions A channel that exists but has no bundle linked is a legitimate user-facing state, not a crash — the CLI prints a clear message and exits 1. But the global catch captured every non-Commander throw as a `$exception`, and the channel name was interpolated into the message, so error tracking minted a fresh issue per channel name and paged the team on a non-bug. - Add a `CliUserError` marker for expected user-facing failures; `shouldCapturePosthogException` skips it (analytics via `trackCommandFailed`/`categorizeCliError` stay intact). - Gate the non-Commander capture path in the global catch on `shouldCapturePosthogException` — previously it captured unconditionally. - Throw `CliUserError` from the expected branches in `currentBundle.ts` and move the channel name out of the message into a context property so residual fingerprints collapse into one issue. Generated-By: PostHog Code Task-Id: de8f6bc9-199a-4f5f-ab58-82c1c8fd3a9f
Contributor
Merging this PR will not alter performance
Comparing Footnotes
|
|
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.



Summary
Problem
channel currentBundleran against a channel name we hadn't seen before — even though nothing was broken.cli/src/index.tscaptured every non-Commander throw as a$exception;shouldCapturePosthogExceptiononly filteredcommander.*codes.Missing API key,Missing appId,Insufficient permissions for channel …).Changes
CliUserErrormarker class for expected, user-facing CLI failures (precedent:MacOSSigningError,BuildRecordReadError).shouldCapturePosthogExceptionskips it, so these never open an error tracking issue — whiletrackCommandFailed/categorizeCliErrorstill count the failure.shouldCapturePosthogException— it previously captured unconditionally, which is why marking the error alone would not have been enough.CliUserErrorfrom the expected-failure branches incli/src/channel/currentBundle.ts, and move the channel name out of the thrown message into acontextproperty so any residual fingerprints collapse into one issue instead of one per channel. The user-facinglog.errorlines (which still include the channel name) are unchanged.Out of scope (noted in the report): the telemetry sanitizer's dotted-name regex that mangles some channel names into
<app_id>— moot now that these are no longer captured, so left untouched.Test plan
bun run test:posthog-exception— extended to assertCliUserErroris never captured (with and without channel context) and that two failures on different channels produce an identical message (one issue, not one per channel).bun run typecheckandbun run lint:oxpass.Screenshots
N/A — telemetry-only change; no visible CLI output change (the user-facing error messages are unchanged).
Checklist
bun run lint:backend && bun run lint.accordingly.
my tests
Created with PostHog Desktop from this inbox report.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.