From 7b19562efcc757934f918483484e6c12399d2bcf Mon Sep 17 00:00:00 2001 From: Vidit Gujrathi <223816573+viditchess64@users.noreply.github.com> Date: Sat, 11 Jul 2026 01:13:30 +0530 Subject: [PATCH 1/2] 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> --- src/viewer/index.html | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/viewer/index.html b/src/viewer/index.html index 305397e93..3bbf3ed04 100644 --- a/src/viewer/index.html +++ b/src/viewer/index.html @@ -1248,7 +1248,16 @@

agentmemory

if (!res.ok) { if (res.status === 401) showViewerAuthPrompt(); console.warn('[viewer] API ' + (fetchOpts.method || 'GET') + ' ' + path + ' returned ' + res.status); - return null; + // Some endpoints (e.g. health) intentionally respond with a non-2xx + // status while still returning a valid JSON body describing the + // degraded state (see #1019). Surface that body instead of + // discarding it as null, which used to make a "critical" health + // response render as "unknown". + try { + return await res.json(); + } catch (parseErr) { + return null; + } } hideViewerAuthPrompt(); return await res.json(); From 9e00b199c8bd3b6b5911535421e5729574b3758b Mon Sep 17 00:00:00 2001 From: Vidit Gujrathi <223816573+viditchess64@users.noreply.github.com> Date: Sat, 11 Jul 2026 01:24:53 +0530 Subject: [PATCH 2/2] 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> --- src/viewer/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/src/viewer/index.html b/src/viewer/index.html index 3bbf3ed04..6ed864f3f 100644 --- a/src/viewer/index.html +++ b/src/viewer/index.html @@ -1256,6 +1256,7 @@

agentmemory

try { return await res.json(); } catch (parseErr) { + console.debug('[viewer] API ' + path + ' non-2xx body was not JSON:', parseErr); return null; } }