fix(cli): stop error tracking user cancels at interactive prompts - #2941
Draft
posthog-eu[bot] wants to merge 1 commit into
Draft
fix(cli): stop error tracking user cancels at interactive prompts#2941posthog-eu[bot] wants to merge 1 commit into
posthog-eu[bot] wants to merge 1 commit into
Conversation
A deliberate Ctrl+C / Escape at an interactive prompt threw a plain `Error`, which the top-level handler shipped to error tracking as an `$exception` and printed as a scary `Error: … cancelled` line. Throw `CliUserError` on every `isCancel()` path so `shouldCapturePosthogException` skips it, and downgrade the site message from `log.error` to `log.warn` because a user-initiated abort is not an error. The top-level handler in `index.ts` no longer prints the redundant `Error: …` line for a `CliUserError`. Adds a shared `uploadCancel()` helper for the three cancel paths in `bundle/upload.ts`. Generated-By: PostHog Code Task-Id: 90f1f1a3-ceed-46b1-bbf5-6795fba9f917
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
Enter your API key:prompt ofcapgo login) threw a plainError.shouldCapturePosthogException()and shipped it to error tracking as an$exception, opening a bogus issue that recurs across many CLI users.Error: … cancelledline for doing exactly what they intended.Changes
CliUserErroron everyisCancel()path —shouldCapturePosthogException()already skips that class, so cancels no longer reach error tracking.log.errortolog.warn: a user-initiated abort is not an error.index.tsno longer prints the redundant, alarmingError: …line for aCliUserError(the call site already printed a clear message).uploadCancel()helper for the three cancel paths inbundle/upload.ts.Swept
isCancel()siteslogin.tsapp/debug.tsapp/delete.tsbundle/cleanup.tsbundle/upload.tsbuild/request.tsorganization/add.ts,set.ts,delete.tsutils.tsScope notes
probe.tsandrun/device.tscancel withexit(1)(never throw), so they produce no$exceptionand are left unchanged.logobjects, widening the change.Test plan
bun run test:posthog-exception— extended to assert a cancel-shapedCliUserErroris not captured.bun run typecheck,bun run lint,bun run test:build-platform-selection,bun run test:upload,bun run test:fail-on-incompatibleall pass.npx @capgo/cli login, press Ctrl+C at the prompt — a singleLogin cancelledwarn line, clean exit, no$exception.Screenshots
No UI change — CLI terminal output only (a warn line instead of an
Error:line on cancel).Checklist
bun run lint:backend && bun run lint.Created with PostHog Desktop from this inbox report.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.