Monitoring: contain failures and stop showing the raw 403 string - #226
Draft
posthog[bot] wants to merge 1 commit into
Draft
Monitoring: contain failures and stop showing the raw 403 string#226posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
A Fleet 403 took out the whole Monitoring section as the internal axios string "Request failed with status code 403", beside a Retry that could never succeed, and the section had no page-level error boundary to contain a failure. - Add a `ForbiddenError` terminal state to `query-state.ts` (mirroring `OfflineError`): the Fleet list hooks throw it on HTTP 403, `queryState` reports `isForbidden`, and `loadErrorProps` swaps in a "not available — check permission or Fleet connection" message and drops the Retry. - Teach the shared `ContentErrorBoundary` the same state, and wrap `monitoring/page.tsx` and its policy/query sub-routes in it so a failed query takes out the content region, not the app shell. - Make the page the only writer of the `search` URL param (the tabs receive it as props). Two `useApiParams` writers let a tab's search write reassert its stale `tab` snapshot, flipping the active tab back to the default. Generated-By: PostHog Desktop Task-Id: 41c386b8-92e3-479d-ad57-3bea65cd57d2
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
api-client.tspasses the upstream body message straight through, and no layer on the Fleet path (use-policies.ts,use-queries.ts,query-state.ts) had a 403 branch, so the raw transport string reached the user.?tab=queriesflipped back to thepoliciesdefault.Changes
ForbiddenErrorinquery-state.tsmirrors the existingOfflineError: the Fleet list hooks throw it on HTTP 403,queryStatereportsisForbidden, andloadErrorPropsswaps in a plain-language "not available — you may not have permission, or Fleet is not connected" message and drops the Retry (a second attempt returns the same rejection).ContentErrorBoundarynow understands the same state, andmonitoring/page.tsxplus itspolicy/querysub-routes are wrapped in it — the wayscripts-v2already is — so a failed query takes out the content region, not the app shell.searchURL param (the tabs receive it as props). TwouseApiParamsinstances both writing the URL let a tab's search write reassert its own staletabsnapshot, which flipped the page back to thepoliciesdefault.Request failed with status code 403+ dead RetryWhy
QA sessions showed users opening Monitoring, seeing a raw error where policies and queries should be, and leaving within seconds (with rage-clicks). The section looked broken when the real cause was a permission or integration problem.
Test plan
npm run type-check— 0 errorsnpm run lint:biomeon changed files — cleannpm run build— all/monitoring*routes buildAgent context
Considered a shared
throwFleetError(res)helper and extending the fix to the detail-view react-query 403 path; both were left out — the helper is over-engineering for two call sites, and the detail 403 render path was outside the reported symptom. The boundary wrap on the detail routes stays as defense-in-depth for thrown errors, matchingscripts-v2.Created with PostHog Desktop from this inbox report.