Commit a8e7d19
fix(viewer): surface health status from non-2xx /agentmemory/health responses (#1046)
* fix(viewer): surface health status from non-2xx /agentmemory/health responses
The health endpoint intentionally returns HTTP 503 when status is
"critical" (src/triggers/api.ts), with a valid JSON body describing
the degraded state. The viewer's shared api() fetch helper treated
any non-ok response as a hard failure and discarded the body,
returning null - so renderDashboard's `h.status || 'unknown'` fallback
always showed "unknown" for a critical backend instead of "critical".
Parse and return the JSON body on non-ok responses too (falling back
to null only if the body isn't valid JSON), so the dashboard reflects
the real health status regardless of the HTTP status code used to
carry it.
Fixes #1019
Signed-off-by: Vidit Gujrathi <223816573+viditchess64@users.noreply.github.com>
* fix(viewer): log non-2xx JSON parse failures at debug level
Address CodeRabbit review: don't silently swallow the parse error when
a non-2xx response body isn't valid JSON - log it at debug level to
help diagnose unexpected content types.
Signed-off-by: Vidit Gujrathi <223816573+viditchess64@users.noreply.github.com>
* fix(viewer): restore non-2xx -> null contract in api(), special-case health
Per review: changing the shared api() helper to return parsed bodies on
non-2xx responses broke callers that treat null as "request failed"
(e.g. loadGraph's disabled/error state). Restore the null contract as
the default and let only the health call opt in via readErrorBody,
since /agentmemory/health intentionally responds 503 with a valid JSON
body when status is critical (#1019).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Signed-off-by: Vidit Gujrathi <223816573+viditchess64@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent 6761a99 commit a8e7d19
1 file changed
Lines changed: 15 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1244 | 1244 | | |
1245 | 1245 | | |
1246 | 1246 | | |
| 1247 | + | |
| 1248 | + | |
1247 | 1249 | | |
1248 | 1250 | | |
1249 | 1251 | | |
1250 | 1252 | | |
1251 | | - | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
1252 | 1265 | | |
1253 | 1266 | | |
1254 | 1267 | | |
| |||
1344 | 1357 | | |
1345 | 1358 | | |
1346 | 1359 | | |
1347 | | - | |
| 1360 | + | |
1348 | 1361 | | |
1349 | 1362 | | |
1350 | 1363 | | |
| |||
0 commit comments