Skip to content

fix(slack): stop reporting expected 403 from Slack connect poll to error tracking#841

Draft
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/slack-poll-suppress-auth-error
Draft

fix(slack): stop reporting expected 403 from Slack connect poll to error tracking#841
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/slack-poll-suppress-auth-error

Conversation

@posthog

@posthog posthog Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Problem

The Slack connect poll (fetchSlackConnected in src/lib/api.ts) hits GET /api/projects/:id/integrations/, which requires the integration:read OAuth 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 on CONNECT_SLACK_SCOPE_ADDITIONS in program-scopes.ts notes "Without integration:read the first poll 403s").

The trouble: the poll's catch handler in SlackConnectScreen.tsx funneled every failure — including this expected 403 — into captureException, 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

  • Add isAuthOrScopeError() in src/lib/api.ts — returns true for 401 (unauthenticated) and 403 (missing scope), reusing the same status inspection handleApiError already relies on.
  • In SlackConnectScreen's poll catch, skip captureException when 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

  • New unit test src/lib/__tests__/api.test.ts covering isAuthOrScopeError for 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.

…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
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

🧙 Wizard CI

Run 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:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci basic-integration
  • /wizard-ci error-tracking-upload-source-maps
  • /wizard-ci mcp-analytics
  • /wizard-ci misc
  • /wizard-ci revenue

Test an individual app:

  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
Show more apps
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci error-tracking-upload-source-maps/android
  • /wizard-ci error-tracking-upload-source-maps/cicd-docker-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-github-actions-docker-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-github-actions-nested-docker-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-github-actions-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-github-actions-single-stage-docker-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-gitlab-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-monorepo-pnpm-node-react
  • /wizard-ci error-tracking-upload-source-maps/cicd-monorepo-raw-node-react
  • /wizard-ci error-tracking-upload-source-maps/cicd-ssh-vps-node-raw
  • /wizard-ci error-tracking-upload-source-maps/flutter
  • /wizard-ci error-tracking-upload-source-maps/ios
  • /wizard-ci error-tracking-upload-source-maps/next
  • /wizard-ci error-tracking-upload-source-maps/next-no-posthog
  • /wizard-ci error-tracking-upload-source-maps/node-raw
  • /wizard-ci error-tracking-upload-source-maps/node-rollup
  • /wizard-ci error-tracking-upload-source-maps/node-rollup-typescript-plugin
  • /wizard-ci error-tracking-upload-source-maps/node-webpack
  • /wizard-ci error-tracking-upload-source-maps/nuxt-3-6
  • /wizard-ci error-tracking-upload-source-maps/nuxt-4-3
  • /wizard-ci error-tracking-upload-source-maps/react-native
  • /wizard-ci error-tracking-upload-source-maps/react-vite
  • /wizard-ci error-tracking-upload-source-maps/rust
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci misc/quack-quack
  • /wizard-ci revenue/stripe

Results will be posted here when complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants