Repository navigation
refactor(frontend): migrate monitoring/health composables off raw fetch (#12363 Phase 2 batch 3) - #12613
Merged
Conversation
…ch (#12363 Phase 2 batch 3) Migrate the app-backend probe fetches in useHealthProbeRegistry and useNetworkStatus onto the fetchWithAuth bridge (JWT injection), preserving the raw-Response handling and graceful-null probe semantics. fetchWithAuth is used rather than ApiClient.rawRequest so the probes keep their exact error handling and do not gain the 401 -> logout/redirect side effect. Adds a dedicated unit test for useHealthProbeRegistry. Skipped (different backend/base): useConnectionTester (arbitrary/external endpoints), useHostInventory and useTLSCredentials (SLM control plane). Refs #12363 Closes #12612
Contributor
✅ SSOT Configuration Compliance: Passing🎉 No hardcoded values detected that have SSOT config equivalents! |
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.
Thinking Path
#12363 Phase 2 migrates the main
autobot-frontendoff rawfetch(. This batch (3) covers the monitoring/health composables — the HTTP ones only. I grepped each candidate, split them by which backend they target and whether the URL is app-owned vs arbitrary, and migrated only the app-backend probes. For probes I used thefetchWithAuthbridge rather thanApiClient.rawRequest, because these sites deliberately keep the rawResponseand swallow errors into a graceful null — routing them throughApiClientwould add its 401 → logout/redirect side effect that plainfetchnever had.What Changed
Per file:
composables/useHealthProbeRegistry.ts— MIGRATED.fetch(${getApiBase()}/system/health/probes)→fetchWithAuth(...). App backend, GET. Now attaches the JWT;.ok/.json()/non-array checks and the "never poison the cache" graceful-null semantics are byte-for-byte preserved.composables/useNetworkStatus.ts— MIGRATED.fetch(${getApiBase()}/health, { method: 'HEAD', cache: 'no-store', signal })→fetchWithAuth(url, {...}). App backend reachability probe;HEAD/cache: 'no-store'/AbortSignal.timeoutand theres.ok || res.status < 500"any non-5xx = online" logic are unchanged.fetchWithAuthreturns a rawResponse, so the probe keeps its exact shape and never triggers a logout on 401.composables/__tests__/useHealthProbeRegistry.test.ts— ADDED. Asserts the registry now routes throughfetchWithAuthagainst/api/system/health/probes, caches, refetches on refresh, and returnsnull(no cache poisoning) on non-ok / non-string-array / thrown-error.Deliberately skipped (grepped + judged; out of scope for the app-backend bridge):
composables/useConnectionTester.ts—fetch(endpoint.value, ...)whereendpoint.valueis an arbitrary/config-supplied URL (documented examples: backend health, Redis ping, LLM tags, external hosts). Forcing it through the app client would prepend the app base URL and inject the app JWT/org headers onto third-party hosts. Left as rawfetchby design.composables/useHostInventory.ts— targets the SLM control-plane backend (getSLMUrl()), a distinct backend from the app; currently sends no app JWT. The app-scopedfetchWithAuthwould inject the wrong (app) token. Needs a dedicated SLM client — see Follow-up.composables/useTLSCredentials.ts— also SLM, with its own token lifecycle (authenticate()/setAuthToken()→Bearer authToken.value). Routing through the app bridge would inject the wrong JWT. See Follow-up.No WebSocket/EventSource builders were present in these files (
usePrometheusMetricsand other WS sites are out of scope per the phase plan).Verification
vue-tsc --noEmit -p tsconfig.app.json→ exit 0 (clean).vitest runonuseHealthProbeRegistry.test.ts,useNetworkStatus.test.ts,useProbeBackedHealth.test.ts→ 24 passed (3 files).fetch(; both now import and usefetchWithAuth.node_modulessymlink (from main tree) used forvue-tsc/vitest, then removed — not committed.Model Used
claude-opus-4-8
Follow-up
Remaining #12363 raw-
fetchinventory (later batches):DesktopInterface,VideoProcessor, plus the infra component set.useHostInventory+useTLSCredentials— need a dedicated SLM auth bridge (analogous toslmApiClientinautobot-slm-frontend); MUST NOT be forced through the appfetchWithAuth/ApiClient.ssot-configURL builders.Refs #12363
Closes #12612