Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(settings): stop reporting transient gateway errors to error tracking (#62319)

posthog[bot]12e84b981c09
diff --git a/frontend/src/initKea.ts b/frontend/src/initKea.ts
index 8a80ca2b1baa..cd7d38ef5fc4 100644
--- a/frontend/src/initKea.ts
+++ b/frontend/src/initKea.ts
@@ -33,6 +33,14 @@ const ERROR_FILTER_ALLOW_LIST = [
'saveEarlyAccessFeature', // Field-level errors handled in earlyAccessFeatureLogic
]
+/*
+Transient gateway/proxy errors. These are infrastructure-level failures (the gateway can't
+reach the backend), not application bugs, so we still toast the user a retryable failure but
+don't report them to error tracking — otherwise sporadic 5xxs surface as noisy code-regression
+issues. 500 is intentionally excluded: those are genuine backend exceptions worth capturing.
+*/
+const TRANSIENT_GATEWAY_STATUSES = [502, 503, 504]
+
interface InitKeaProps {
state?: Record<string, any>
routerHistory?: any
@@ -132,7 +140,9 @@ export function initKea({
if (!errorsSilenced) {
console.error({ error, reducerKey, actionKey })
}
- posthog.captureException(error)
+ if (!TRANSIENT_GATEWAY_STATUSES.includes(error?.status)) {
+ posthog.captureException(error)
+ }
},
}),
subscriptionsPlugin,
diff --git a/frontend/src/scenes/userLogic.test.ts b/frontend/src/scenes/userLogic.test.ts
index 1c8c63ae2731..c62089fd5818 100644
--- a/frontend/src/scenes/userLogic.test.ts
+++ b/frontend/src/scenes/userLogic.test.ts
@@ -1,6 +1,7 @@
import { MOCK_DEFAULT_USER } from 'lib/api.mock'
import { expectLogic } from 'kea-test-utils'
+import posthog from 'posthog-js'
import api from 'lib/api'
@@ -214,5 +215,32 @@ describe('userLogic', () => {
.toDispatchActions(['updateUserFailure'])
.toMatchValues({ user: userWithLightTheme })
})
+
+ it.each([502, 503, 504])(
+ 'does not report transient gateway error %s to error tracking but still fails the update',
+ async (status) => {
+ const captureSpy = jest.spyOn(posthog, 'captureException').mockImplementation(() => undefined as any)
+ jest.spyOn(api, 'update').mockRejectedValue({ status, statusText: 'Bad Gateway' })
+
+ await expectLogic(userLogic, () => {
+ userLogic.actions.updateUser({ email: '[email protected]' })
+ })
+ .toDispatchActions(['updateUserFailure'])
+ .toNotHaveDispatchedActions(['updateUserSuccess'])
+
+ expect(captureSpy).not.toHaveBeenCalled()
+ }
+ )
+
+ it('reports a genuine backend error (500) to error tracking', async () => {
+ const captureSpy = jest.spyOn(posthog, 'captureException').mockImplementation(() => undefined as any)
+ jest.spyOn(api, 'update').mockRejectedValue({ status: 500, statusText: 'Internal Server Error' })
+
+ await expectLogic(userLogic, () => {
+ userLogic.actions.updateUser({ email: '[email protected]' })
+ }).toDispatchActions(['updateUserFailure'])
+
+ expect(captureSpy).toHaveBeenCalled()
+ })
})
})