From 782ecf3cea0e7e8c48fcf351d83964c1bc3aeb7d Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 30 Jan 2026 06:33:52 +0000 Subject: [PATCH] Refactor telemetry aggregator regex for stricter error detection - Update `scripts/agent/telemetry-aggregator.mjs` to use a stricter regex for parsing generic logs. - Require brackets (e.g., `[ERROR]`, `[WARN]`) or trailing colons/word boundaries (e.g., `Error:`, `FAIL`) to match errors. - Prevent false positives from status messages like "0 errors" or "0 failures". - Support `[WARN]` as Medium severity. - Ensure PII sanitization and `ENABLE_TELEMETRY` guardrails are preserved. Co-authored-by: PR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> --- scripts/agent/telemetry-aggregator.mjs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/agent/telemetry-aggregator.mjs b/scripts/agent/telemetry-aggregator.mjs index 615799b2..33541709 100644 --- a/scripts/agent/telemetry-aggregator.mjs +++ b/scripts/agent/telemetry-aggregator.mjs @@ -147,19 +147,26 @@ function collectGenericLogs(filepath, sourceName) { for (const line of lines) { // Simple heuristic for generic logs: look for "Error:" or "Exception:" // and capture following lines that look like stack traces (start with 'at ' or are indented) + // Also support bracketed log levels like [ERROR], [FAIL], [CRITICAL], [WARN] - const isErrorStart = /Error:|Exception:|FAIL|CRITICAL/.test(line); + const errorMatch = line.match(/(?:\[\s*(?:ERROR|FAIL|CRITICAL|EXCEPTION|WARN|WARNING)\s*\])|(?:\b(?:Error|Exception|Warning):)|(?:\b(?:FAIL|CRITICAL)\b)/i); + const isErrorStart = !!errorMatch; const isStackLine = /^\s+at /.test(line) || /^\s+/.test(line); // Indented lines often follow errors if (isErrorStart) { if (currentError) { errors.push(currentError); } + + let severity = 'High'; + if (line.match(/CRITICAL/i)) severity = 'Critical'; + else if (line.match(/WARN|WARNING/i)) severity = 'Medium'; + currentError = { source: sourceName, title: sanitize(line.trim()), details: [sanitize(line.trim())], - severity: 'High' + severity: severity }; } else if (currentError && isStackLine) { currentError.details.push(sanitize(line.trim()));