fix(slack): stop reporting expected 403 from Slack connect poll to error tracking#841
Draft
posthog[bot] wants to merge 1 commit into
Draft
fix(slack): stop reporting expected 403 from Slack connect poll to error tracking#841posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
…ror tracking The Slack connect poll hits GET /api/projects/:id/integrations/, which requires the integration:read OAuth scope. When the token lacks it, PostHog returns 403 — a case the code already anticipates and degrades from (see CONNECT_SLACK_SCOPE_ADDITIONS). But the poll's catch handler funneled every failure into captureException, so an expected, handled fallback surfaced as a fresh error-tracking issue. Add isAuthOrScopeError() in api.ts (401/403) and skip captureException for those statuses in SlackConnectScreen, keeping the existing stop-polling + connect-nudge fallback. Genuinely unexpected failures are still reported. Generated-By: PostHog Code Task-Id: 7a8242d9-7d0b-4dbf-ae4d-953bde2f03e5
🧙 Wizard CIRun the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands: Test all apps:
Test all apps in a directory:
Test an individual app:
Show more apps
Results will be posted here when complete. |
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.
Problem
The Slack connect poll (
fetchSlackConnectedinsrc/lib/api.ts) hitsGET /api/projects/:id/integrations/, which requires theintegration:readOAuth scope. When the caller's token doesn't have it, PostHog returns 403 — a case the code already anticipates and gracefully degrades from (the comment onCONNECT_SLACK_SCOPE_ADDITIONSinprogram-scopes.tsnotes "Without integration:read the first poll 403s").The trouble: the poll's catch handler in
SlackConnectScreen.tsxfunneled every failure — including this expected 403 — intocaptureException, so an already-handled fallback turned into a fresh error-tracking issue. Net effect is error-tracking noise for the team, not a broken user flow: the screen already stops polling and shows the connect nudge.Changes
isAuthOrScopeError()insrc/lib/api.ts— returns true for 401 (unauthenticated) and 403 (missing scope), reusing the same status inspectionhandleApiErroralready relies on.SlackConnectScreen's poll catch, skipcaptureExceptionwhen the error is an auth/scope error. The existing behavior (stop polling, fall back to the connect nudge, mark not-connected) is unchanged — only genuinely unexpected failures are still reported.Test plan
src/lib/__tests__/api.test.tscoveringisAuthOrScopeErrorfor 401/403 (true), 404/500 (false), and non-axios errors (false).pnpm build && pnpm test— full suite green (1281 tests).pnpm lint— no new warnings/errors from the change.Created with PostHog Code from an inbox report.