Skip to content

fix: don't report expected 401/403 from Slack-connected poll as exceptions#784

Draft
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/slack-poll-expected-401
Draft

fix: don't report expected 401/403 from Slack-connected poll as exceptions#784
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/slack-poll-expected-401

Conversation

@posthog

@posthog posthog Bot commented Jul 1, 2026

Copy link
Copy Markdown

Problem

The Slack-connected poll on SlackConnectScreen was reporting expected auth failures to error tracking as if they were real exceptions.

fetchSlackConnected (src/lib/api.ts) does an axios.get with no try/catch, so it throws on any non-2xx. The poll's .catch degrades gracefully — it stops polling and falls back to the connect nudge — but then reports the error via analytics.captureException(..., { step: 'slack_connected_check' }). A plain token-expiry 401 (or a missing-integration:read-scope 403) is expected and non-actionable, yet it showed up as a real exception, creating error-tracking noise on every stale-token poll.

Changes

  • Add httpStatusOf(error) to api.ts to extract an axios error's HTTP status without pulling axios into the screen.
  • In the poll's .catch, downgrade a 401/403 to a debug log plus a lightweight slack connect check skipped breadcrumb event. Any other error is still captured as an exception. The graceful degradation (stop polling, show the nudge) is unchanged.

Why: token expiry during the poll is already handled correctly; it was only surfacing as noise in error tracking rather than indicating a broken flow.

Test plan

  • New unit test src/lib/__tests__/api-http-status.test.ts covers httpStatusOf for axios errors with/without a response and non-axios errors.
  • pnpm build && pnpm test && pnpm lint all pass (0 lint errors).

Created with PostHog Code from an inbox report.

…tions

The SlackConnectScreen poll calls fetchSlackConnected, which throws on any
non-2xx. The catch degrades gracefully (stops polling, falls back to the
connect nudge) but then reports every failure via captureException. A plain
token-expiry 401 (or a missing-scope 403) is expected here and non-actionable,
yet it surfaces as a real exception in error tracking.

Add httpStatusOf() to api.ts and branch on it in the poll's catch: a 401/403 is
downgraded to a debug log plus a lightweight "slack connect check skipped"
breadcrumb event, while anything else is still captured as an exception.

Generated-By: PostHog Code
Task-Id: b146df1d-03fd-41f1-80bb-229fd5525490
@github-actions

github-actions Bot commented Jul 1, 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