fix(desktop): return typed non-500 for expected Sentry poll states (#9139)#9145
Conversation
…9139) /v1/webhooks/sentry/poll returned a blanket 500 for any Sentry API non-2xx, network error, or parse failure. In prod Sentry returns 403 Forbidden on every ~5min poll (token lacks permission), so desktop-backend logged persistent 500s (24x/2h) that mask real failures. Classify expected external states (auth expiry/permission, rate limit, upstream/network failure, unparseable body) as typed 2xx skipped responses with compact warn logs instead of 500. Adds a hermetic regression test for the status classification. Note: the underlying 403 is an ops issue (SENTRY_AUTH_TOKEN needs re-permissioning) tracked separately; this fix stops the error-log noise. Verified: cargo test (2 new tests pass), cargo build clean, rustfmt applied.
|
Reviewed the Sentry poll fix for #9139 — this looks clean and well-targeted. What it does Strengths
Verification
Minor note (non-blocking) Net: solid fix for the log-noise issue. Holding off on formal approval per review process; a maintainer should be good to merge if they agree with the error-vs-skipped boundary. cc @kodjima33 |
Bug (#9139)
desktop-backendreturns repeated500s onPOST /v1/webhooks/sentry/pollin prod (24x/2h), masking real failures.Root cause
poll_sentry_feedbackreturns a blanketStatusCode::INTERNAL_SERVER_ERRORwhenever the Sentry API call is non-2xx, the request fails, or the body doesn't parse. Prod logs show the actual state is a persistent403 Forbiddenfrom Sentry on every ~5-min poll (theSENTRY_AUTH_TOKENlacks permission), so every poll emits a 500 even though nothing in this service is broken:Fix
Classify expected external states — auth expiry/permission (401/403), rate limit (429), upstream 5xx, network unreachable, and unparseable body — as a typed
2xx"skipped"response with a compactwarnlog instead of a500. The success path is unchanged. Genuine server misconfiguration (missingSENTRY_ADMIN_UID/SENTRY_AUTH_TOKEN) still returns 500.Response shape mirrors the success body so callers can treat
ok/skippeduniformly:{ "status": "skipped", "reason": "sentry_auth_error", "sentry_status": 403, "created": 0, "skipped": 0, "total_fetched": 0 }Note (separate ops action)
The underlying
403is an ops issue —SENTRY_AUTH_TOKENfor orgmediar-n5needs re-permissioning/rotation. This PR only stops the error-log noise; polling stays a no-op until the token is fixed.Verification
cargo test— 2 new hermetic regression tests pass (sentry_poll_skip_reason_classifies_expected_states,sentry_poll_skipped_body_is_typed_non_500_shape)cargo buildclean,rustfmtapplied🤖 automated by hourly watchdog; opened for review, not merged.