From f8cef5c99d1b60ff6deb417041f2ab8c8b27af7a Mon Sep 17 00:00:00 2001 From: Codex Date: Thu, 18 Jun 2026 03:50:45 +0000 Subject: [PATCH] fix: parse web probe report envelopes --- scripts/src/hwlab-node.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/src/hwlab-node.ts b/scripts/src/hwlab-node.ts index 46165078..d2f75fbe 100644 --- a/scripts/src/hwlab-node.ts +++ b/scripts/src/hwlab-node.ts @@ -9878,10 +9878,20 @@ function redactKnownSecrets(text: string, secrets: string[]): string { } function parseJsonObject(text: string): Record | null { + const trimmed = text.trim(); + if (trimmed.length === 0) return null; try { - const parsed = JSON.parse(text) as unknown; + const parsed = JSON.parse(trimmed) as unknown; return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed as Record : null; } catch { + const start = trimmed.indexOf("{"); + const end = trimmed.lastIndexOf("}"); + if (start >= 0 && end > start) { + try { + const parsed = JSON.parse(trimmed.slice(start, end + 1)) as unknown; + return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed as Record : null; + } catch {} + } return null; } }