fix: stop spamming Sentry when draft publish/discard hits expected 4xx#5088
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix: stop spamming Sentry when draft publish/discard hits expected 4xx#5088cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
The agent sidebar's DraftActionsWidget unconditionally called
console.error whenever the publish/discard request returned a non-OK
response. The frontend Sentry SDK is configured with
captureConsoleIntegration({ levels: ['warn', 'error'] }), so a normal
business-logic outcome — most commonly a 400 'only draft versions can
be published' when the version was already published from another
tab/CLI — was being shipped to Sentry as a noisy error event.
Handle 4xx responses as expected outcomes: surface the server's
message inline (no console.error, no Sentry event) and silently
dismiss the widget when the response indicates the draft is stale
(version already published, missing, or owned by someone else).
Reserve console.error / Sentry for true failures (5xx and network
errors).
|
👋 Commands for maintainers:
|
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
Fixes the Sentry alert:
publish failed: 400 {"code":9,"message":"only draft versions can be published","details":[]}(#7516282874).Root cause
The agent sidebar's
DraftActionsWidgetexposes Publish / Discard buttons for the latest draft.callApiunconditionally calledconsole.errorwhenever the request returned a non-OK response:The frontend Sentry SDK is initialized with
captureConsoleIntegration({ levels: ["warn", "error"] })(seeweb_src/src/sentry.ts), so this log is shipped as a Sentry event. But the case being hit here is a normal business-logic outcome — the draft was already published from another tab, the CLI, or by another collaborator — so the server correctly responds with400 FailedPrecondition: only draft versions can be published. Treating that as an unhandled error pollutes Sentry and obscures real bugs.Fix
In
DraftActionsWidget:messageinline in the widget (role="alert").4xxresponses, treat them as expected outcomes — noconsole.error, no Sentry event.only draft versions can be published,version not found,version owner mismatch), callonDismissso the bar disappears instead of leaving a dead Publish button.console.errorfor genuine failures (5xx, network errors).Tests
Added
DraftActionsWidget.spec.tsxcovering:console.error) when the API returns the stale-draft 400.console.error(and surfaces inline) for 5xx responses so real failures keep flowing to Sentry.onDismissafter a successful publish.All 4 new tests pass.