fix: stop reporting expected function errors#7316
Merged
byrichardpowell merged 3 commits intomainfrom Apr 15, 2026
Merged
Conversation
AbortError's docstring says "shouldn't be reported as a bug" and shouldReportErrorAsUnexpected correctly returns false for it, setting exitMode to 'expected_error'. But sendErrorToBugsnag ignored that classification and reported all Error instances regardless. This adds an early return in sendErrorToBugsnag when exitMode is 'expected_error', making the reporting layer respect the classification that already exists. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Updates CLI Kit’s Bugsnag reporting behavior to respect the already-computed error classification, preventing “expected” (non-bug) errors from being sent to Bugsnag/Observe.
Changes:
- Add an early return in
sendErrorToBugsnagwhenexitMode === 'expected_error'to skip reporting. - Update the existing test to assert that expected errors are not reported.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
packages/cli-kit/src/public/node/error-handler.ts |
Skips Bugsnag notification when the error is classified as expected_error. |
packages/cli-kit/src/public/node/error-handler.test.ts |
Updates the relevant test to ensure expected errors are not reported. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ribe block - Return `unhandled: undefined` instead of `false` for consistency with other `reported: false` early returns - Move test from "sends errors to Bugsnag" to "skips sending errors to Bugsnag" describe block where it belongs - Assert on the debug log message to match existing test patterns Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
sendErrorToBugsnagreports allErrorinstances regardless of their classification. This meansAbortError— whose docstring says "shouldn't be reported as a bug" — still gets sent, generating significant noise in Observe.This PR adds an early return when
exitMode === 'expected_error', making the reporting layer respect the classification thatshouldReportErrorAsUnexpectedalready computes correctly.Problem
The Observe error group
Build step "Build Function" failed: Failed to build function.has ~12k events/month across all CLI versions (3.82.0+). Investigation showed:client-steps.tswrapper that changed the message format, creating a new grouping hashbuildFunctionExtensionwraps these inAbortErrorwith the comment "To avoid random user-code errors being reported as CLI bugs" — butsendErrorToBugsnagignores that and reports them anywayThe classification chain works correctly:
Fix
5-line early return in
sendErrorToBugsnag:Impact
6 callsites use
sendErrorToBugsnag. 5 use hardcodedexitMode, 1 computes it dynamically:errorHandler)expected_errorunexpected_errorunexpected_errorexpected_errorenv_auto_upgrade_success)expected_errorEvery callsite that stops reporting was already explicitly classified as
expected_error— either byshouldReportErrorAsUnexpectedor by the developer hardcoding it. No signal is lost that isn't tracked through other channels.Test plan
processes AbortErrors as handled→skips reporting for expected errors🤖 Generated with Claude Code
Closes shop/issues#32997