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(signals): stop reporting expected scout config access errors (#85234)

Carlos Marchal93234fe5b676
diff --git a/products/signals/frontend/inbox/logics/scoutFleetLogic.test.ts b/products/signals/frontend/inbox/logics/scoutFleetLogic.test.ts
index bd90198e8762..0644571cb8e1 100644
--- a/products/signals/frontend/inbox/logics/scoutFleetLogic.test.ts
+++ b/products/signals/frontend/inbox/logics/scoutFleetLogic.test.ts
@@ -4,6 +4,7 @@ import { router } from 'kea-router'
import { expectLogic } from 'kea-test-utils'
import posthog from 'posthog-js'
+import { ApiError } from 'lib/api-error'
import { organizationLogic } from 'scenes/organizationLogic'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
@@ -229,6 +230,20 @@ describe('scoutFleetLogic', () => {
expect(logic.values.scoutConfigs).toBeNull()
})
+ // The 500 row is the point of this case: a guard wide enough to swallow it would leave a real
+ // scout-configs outage looking identical to a project the user simply cannot reach.
+ it.each([
+ [403, 'loadScoutConfigsSuccess'],
+ [404, 'loadScoutConfigsSuccess'],
+ [500, 'loadScoutConfigsFailure'],
+ ])('resolves a %s from the config list to %s', async (status, expectedAction) => {
+ mockSignalsScoutConfigList.mockRejectedValueOnce(new ApiError('nope', status))
+
+ logic.actions.loadScoutConfigs()
+
+ await expectLogic(logic).toDispatchActions([expectedAction])
+ })
+
it('sends newer queued updates after an earlier request fails', async () => {
const firstRequest = deferred<SignalScoutConfigApi>()
const failingRequest = deferred<SignalScoutConfigApi>()
diff --git a/products/signals/frontend/inbox/logics/scoutFleetLogic.ts b/products/signals/frontend/inbox/logics/scoutFleetLogic.ts
index dc4dff022342..bbeb47e9ab4d 100644
--- a/products/signals/frontend/inbox/logics/scoutFleetLogic.ts
+++ b/products/signals/frontend/inbox/logics/scoutFleetLogic.ts
@@ -4,6 +4,7 @@ import { actionToUrl, router, urlToAction } from 'kea-router'
import { lemonToast } from '@posthog/lemon-ui'
+import { ApiError } from 'lib/api-error'
import { dayjs } from 'lib/dayjs'
import { reconcileById } from 'lib/utils/objects'
import { aiConsentLogic } from 'scenes/settings/organization/aiConsentLogic'
@@ -479,11 +480,22 @@ export const scoutFleetLogic = kea<scoutFleetLogicType>([
if (!teamId) {
return null
}
- const configs = await signalsScoutConfigList(String(teamId))
- // The 60s poll refetches all configs every cycle. Reconcile against the previous
- // list so an unchanged fleet keeps the same references — otherwise the whole
- // roster re-renders on every poll even when nothing changed.
- return reconcileById(values.scoutConfigs ?? [], configs, (config) => config.id)
+ try {
+ const configs = await signalsScoutConfigList(String(teamId))
+ // The 60s poll refetches all configs every cycle. Reconcile against the previous
+ // list so an unchanged fleet keeps the same references — otherwise the whole
+ // roster re-renders on every poll even when nothing changed.
+ return reconcileById(values.scoutConfigs ?? [], configs, (config) => config.id)
+ } catch (error) {
+ // A stale project id left in the URL by a project switch, or a member without
+ // access, are expected — degrade to the same null the no-team guard returns
+ // instead of reporting them. Anything else, notably a 5xx, still throws so a
+ // real backend failure keeps reaching error tracking.
+ if (error instanceof ApiError && (error.status === 403 || error.status === 404)) {
+ return null
+ }
+ throw error
+ }
},
},
],