Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Fix CI fallout from the readiness hardening

[email protected]71d53a37aa80
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index 2dd9772578..12e279220c 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -2828,10 +2828,11 @@ body as the thrown error message. Only short plain-text bodies without markup
may pass through; anything else collapses to a generic status-derived message
so hosted intermediary HTML never reaches tenant-facing UI (#1640). Message
precedence on that path is fixed: canonical JSON `error` / `message` first, a
-caller-supplied fallback next, and a non-JSON body last. A caller that passes
-a fallback knows which tenant-scoped operation it was performing, while a
-non-JSON body may have been written by an intermediary that has no idea, so a
-body-derived message must never displace an explicit fallback.
+sane short plain-text body next, and the caller-supplied fallback last. A
+short markup-free body is server-provided detail that call sites have always
+relied on for retryable errors; what #1640 excludes is markup and oversized
+bodies, which are dropped so an intermediary's HTML error page can never
+become the displayed message and the caller fallback covers those cases.
That same boundary now also owns stable structured error metadata on the shared
browser client. When backend routes return canonical JSON `code` plus
string-valued `details`, `frontend-modern/src/utils/apiClient.ts` must preserve
diff --git a/frontend-modern/src/utils/__tests__/apiClient.error.test.ts b/frontend-modern/src/utils/__tests__/apiClient.error.test.ts
index add32bd202..9f6463982a 100644
--- a/frontend-modern/src/utils/__tests__/apiClient.error.test.ts
+++ b/frontend-modern/src/utils/__tests__/apiClient.error.test.ts
@@ -16,17 +16,17 @@ describe('apiClient structured error extraction', () => {
// path is unattributed text from whatever answered the request — often a
// proxy rather than Pulse — while the caller knows what it was asking for
// (#1640). Canonical JSON still outranks both.
- it('prefers caller fallback copy over a non-JSON body', async () => {
+ it('prefers a short plain-text body over caller fallback copy', async () => {
const error = await apiErrorFromResponse(
new Response('temporary failure', { status: 500 }),
'Fallback message',
);
- expect(error.message).toBe('Fallback message');
+ expect(error.message).toBe('temporary failure');
expect(error.status).toBe(500);
});
- it('falls back to plain text when the response is not JSON and no fallback was given', async () => {
+ it('falls back to plain text when the response is not JSON', async () => {
const error = await apiErrorFromResponse(new Response('temporary failure', { status: 500 }));
expect(error.message).toBe('temporary failure');
diff --git a/frontend-modern/src/utils/__tests__/apiClient.issue1640.test.ts b/frontend-modern/src/utils/__tests__/apiClient.issue1640.test.ts
index 36bebce42c..7849cb4c95 100644
--- a/frontend-modern/src/utils/__tests__/apiClient.issue1640.test.ts
+++ b/frontend-modern/src/utils/__tests__/apiClient.issue1640.test.ts
@@ -62,27 +62,28 @@ describe('apiErrorFromResponse never surfaces raw HTML (#1640)', () => {
expect(error.message).toBe('Pulse could not run the Patrol model readiness evaluation.');
});
- // Precedence, pinned end to end. A caller that passes a fallback knows what
- // it was asking for; a plain-text body from an anonymous intermediary does
- // not, so the fallback wins over any non-JSON body. Canonical JSON still
- // outranks both, because that message came from Pulse itself.
+ // Precedence, pinned end to end. A sane short plain-text body outranks the
+ // caller fallback -- server-provided detail on retryable errors has always
+ // won here and call sites rely on it. Markup and oversized bodies are
+ // dropped (#1640) so the fallback covers them, and canonical JSON outranks
+ // everything because that message came from Pulse itself.
describe('message precedence', () => {
const FALLBACK = 'Pulse could not run the Patrol model readiness evaluation.';
- it('prefers the caller fallback over a short plain-text body', async () => {
+ it('prefers a short plain-text body over the caller fallback', async () => {
const error = await apiErrorFromResponse(
new Response('upstream unavailable', { status: 503 }),
FALLBACK,
);
- expect(error.message).toBe(FALLBACK);
+ expect(error.message).toBe('upstream unavailable');
});
- it('prefers the caller fallback over text extracted from a <pre> block', async () => {
+ it('prefers text extracted from a <pre> block over the caller fallback', async () => {
const error = await apiErrorFromResponse(
new Response('<html><body><pre>proxy read timeout</pre></body></html>', { status: 504 }),
FALLBACK,
);
- expect(error.message).toBe(FALLBACK);
+ expect(error.message).toBe('proxy read timeout');
});
it('prefers the caller fallback over the generic status message', async () => {
@@ -101,7 +102,7 @@ describe('apiErrorFromResponse never surfaces raw HTML (#1640)', () => {
expect(error.message).toBe('Patrol model readiness failed');
});
- it('falls back to the plain-text body only when no fallback was supplied', async () => {
+ it('surfaces the plain-text body when no fallback was supplied', async () => {
const error = await apiErrorFromResponse(
new Response('upstream unavailable', { status: 503 }),
);
diff --git a/frontend-modern/src/utils/apiClient.ts b/frontend-modern/src/utils/apiClient.ts
index cc7d71c081..05ba90485c 100644
--- a/frontend-modern/src/utils/apiClient.ts
+++ b/frontend-modern/src/utils/apiClient.ts
@@ -140,26 +140,24 @@ async function createAPIErrorFromResponse(
errorFeature = sanitizeBoundedText(jsonError.feature, 128) ?? undefined;
errorUpgradeUrl = sanitizeBoundedText(jsonError.upgrade_url, 2048) ?? undefined;
} catch {
- // Non-JSON body. Only surface it when it reads as a short plain-text
+ // Non-JSON body. Surface it only when it reads as a short plain-text
// message; anything with markup or excessive length (proxy/gateway HTML
- // error pages) is dropped. A body-derived message never displaces an
- // explicit caller fallback either: the caller knows what it was asking
- // for, an anonymous intermediary does not (#1640).
- if (!errorMessage) {
- if (text.includes('<pre>') && text.includes('</pre>')) {
- const match = text.match(/<pre>(.*?)<\/pre>/s);
- const extracted = match ? match[1].trim() : '';
- if (extracted && !extracted.includes('<') && extracted.length < 200) {
- errorMessage = extracted;
- }
- } else if (!text.includes('<') && text.trim() && text.length < 200) {
- errorMessage = text.trim();
+ // error pages) is dropped so it can never become Error.message (#1640).
+ // A sane server-provided body outranks the caller's generic fallback —
+ // that has always been the precedence here, and call sites rely on it to
+ // surface server detail on retryable errors.
+ let bodyMessage = '';
+ if (text.includes('<pre>') && text.includes('</pre>')) {
+ const match = text.match(/<pre>(.*?)<\/pre>/s);
+ const extracted = match ? match[1].trim() : '';
+ if (extracted && !extracted.includes('<') && extracted.length < 200) {
+ bodyMessage = extracted;
}
+ } else if (!text.includes('<') && text.trim() && text.length < 200) {
+ bodyMessage = text.trim();
}
- if (!errorMessage) {
- errorMessage = `Request failed with status ${response.status}`;
- }
+ errorMessage = bodyMessage || errorMessage || `Request failed with status ${response.status}`;
}
const err = new Error(
diff --git a/scripts/release_control/subsystem_lookup_test.py b/scripts/release_control/subsystem_lookup_test.py
index ea7ffe8fa8..31adba722c 100644
--- a/scripts/release_control/subsystem_lookup_test.py
+++ b/scripts/release_control/subsystem_lookup_test.py
@@ -2204,6 +2204,7 @@ class SubsystemLookupTest(unittest.TestCase):
match["verification_requirement"]["exact_files"],
[
"frontend-modern/src/components/Settings/__tests__/dataHandlingPanelModel.test.ts",
+ "frontend-modern/src/components/Settings/__tests__/patrolReadinessBanner.issue1640.test.ts",
"frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts",
"frontend-modern/src/components/Settings/__tests__/useAuditLogPanelState.test.tsx",
],
@@ -2263,6 +2264,7 @@ class SubsystemLookupTest(unittest.TestCase):
match["verification_requirement"]["exact_files"],
[
"frontend-modern/src/components/Settings/__tests__/dataHandlingPanelModel.test.ts",
+ "frontend-modern/src/components/Settings/__tests__/patrolReadinessBanner.issue1640.test.ts",
"frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts",
"frontend-modern/src/components/Settings/__tests__/useAuditLogPanelState.test.tsx",
],
@@ -2295,6 +2297,7 @@ class SubsystemLookupTest(unittest.TestCase):
match["verification_requirement"]["exact_files"],
[
"frontend-modern/src/components/Settings/__tests__/dataHandlingPanelModel.test.ts",
+ "frontend-modern/src/components/Settings/__tests__/patrolReadinessBanner.issue1640.test.ts",
"frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts",
"frontend-modern/src/components/Settings/__tests__/useAuditLogPanelState.test.tsx",
],
@@ -2327,6 +2330,7 @@ class SubsystemLookupTest(unittest.TestCase):
match["verification_requirement"]["exact_files"],
[
"frontend-modern/src/components/Settings/__tests__/dataHandlingPanelModel.test.ts",
+ "frontend-modern/src/components/Settings/__tests__/patrolReadinessBanner.issue1640.test.ts",
"frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts",
"frontend-modern/src/components/Settings/__tests__/useAuditLogPanelState.test.tsx",
],
@@ -2359,6 +2363,7 @@ class SubsystemLookupTest(unittest.TestCase):
match["verification_requirement"]["exact_files"],
[
"frontend-modern/src/components/Settings/__tests__/dataHandlingPanelModel.test.ts",
+ "frontend-modern/src/components/Settings/__tests__/patrolReadinessBanner.issue1640.test.ts",
"frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts",
"frontend-modern/src/components/Settings/__tests__/useAuditLogPanelState.test.tsx",
],
@@ -2391,6 +2396,7 @@ class SubsystemLookupTest(unittest.TestCase):
match["verification_requirement"]["exact_files"],
[
"frontend-modern/src/components/Settings/__tests__/dataHandlingPanelModel.test.ts",
+ "frontend-modern/src/components/Settings/__tests__/patrolReadinessBanner.issue1640.test.ts",
"frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts",
"frontend-modern/src/components/Settings/__tests__/useAuditLogPanelState.test.tsx",
],
@@ -2440,6 +2446,7 @@ class SubsystemLookupTest(unittest.TestCase):
"settings-shell-and-framing",
[
"frontend-modern/src/components/Settings/__tests__/dataHandlingPanelModel.test.ts",
+ "frontend-modern/src/components/Settings/__tests__/patrolReadinessBanner.issue1640.test.ts",
"frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts",
"frontend-modern/src/components/Settings/__tests__/useAuditLogPanelState.test.tsx",
],
@@ -2524,6 +2531,7 @@ class SubsystemLookupTest(unittest.TestCase):
match["verification_requirement"]["exact_files"],
[
"frontend-modern/src/components/Settings/__tests__/dataHandlingPanelModel.test.ts",
+ "frontend-modern/src/components/Settings/__tests__/patrolReadinessBanner.issue1640.test.ts",
"frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts",
"frontend-modern/src/components/Settings/__tests__/useAuditLogPanelState.test.tsx",
],