From 8d00c6949d19338e949618ddae4f1aef592cf58b Mon Sep 17 00:00:00 2001 From: Agando Date: Fri, 23 Oct 2026 15:55:51 +0200 Subject: fix(newos4): empty-pipeline crash, stacks in reports, frame in digest + dashboard (v4.6.55) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause: splitPipe() splits on every '|', so `help |`, `| wc -l`, `a || b` produced a stage with no argv and executePipeChain() called parts[0].toLowerCase() on undefined — 989 occurrences, first filed 2026-10-20, unfixable from the report because bug reports dropped the stack that named executePipeChain:3955. Same unguarded read existed in _classify(). - terminal.js: _classify() returns an inert classification for empty argv; executePipeChain() parses each stage once, filters stages with no argv (so the last real stage stays final), warns only when the whole pipeline is empty. Last-stage test now compares against the filtered length. - module-system.js: `bug` diagnostics include the stack (10 frames, 1200 chars); auto-filed reports carry it too — they are the majority of the inbox and were previously message-only. - report.php: per-stack 2 KB cap; fingerprint pinned to message/source/count so adding `stack` cannot break dedupe against reports filed before today. - ingest.php: first_frame() parsed once on ingest, stored as `frame` on each signature. - newos4-triage.py: FRAME| line with the first application frame. - dashboard.php: frame under each Top Errors row. - modules/test/test-pipe-guard.js: ordering tripwire (guard must precede the parts[0] read). Verified: test RED exit=1 -> GREEN exit=0; browser matrix on v4.6.55 (help |, | wc -l, echo hi || echo bye, ls | | wc -l, |) -> 0 new error signatures, "|" warns; auto-filed report now carries stack (RPT-...f3e31124, archived after the probe); frame = modules/core/core-bundle.js:3955:42; maintain OK; skill audit 7/7. --- api/debug/ingest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'api/debug/ingest.php') diff --git a/api/debug/ingest.php b/api/debug/ingest.php index 7388bce..98354fe 100644 --- a/api/debug/ingest.php +++ b/api/debug/ingest.php @@ -80,6 +80,20 @@ function norm_ts($s, $fallback) { return gmdate('c', $t); // always +00:00, never Z } +// Where did it happen? Parsed ONCE here so the digest (Python) and the dashboard (PHP) read the +// same value instead of re-implementing this regex twice. Returns 'modules/core/x.js:12:3'. +function first_frame($stack) { + if (!is_string($stack) || $stack === '') return null; + foreach (preg_split('/\R/', $stack) as $i => $line) { + if ($i === 0 || !preg_match('/^\s+at /', $line)) continue; // line 0 is "TypeError: ..." + if (preg_match('#([\w./-]+\.js)(?:\?v=[\w.]+)?:(\d+):(\d+)#', $line, $m)) { + $p = preg_replace('#^.*?/spaces/newos4/#', '', $m[1]); + return $p . ':' . $m[2] . ':' . $m[3]; + } + } + return null; +} + $processed = 0; // entries handled (NOT occurrences) — the client's truncation warning uses this foreach ($errors as $e) { $processed++; @@ -103,6 +117,7 @@ foreach ($errors as $e) { $allErrors[$idx]['ingested_at'] = $now; if (!empty($e['stack'])) { $allErrors[$idx]['stack'] = substr($e['stack'], 0, 2000); + $allErrors[$idx]['frame'] = first_frame($e['stack']) ?? ($allErrors[$idx]['frame'] ?? null); } $ingested += $delta; } @@ -118,6 +133,7 @@ foreach ($errors as $e) { 'source' => $e['source'] ?? '', 'module' => $e['module'] ?? null, 'stack' => isset($e['stack']) ? substr($e['stack'], 0, 2000) : null, + 'frame' => first_frame($e['stack'] ?? null), 'session_id' => $sessionId, 'count' => $delta, 'first_seen' => norm_ts($e['firstSeen'] ?? null, $now), -- cgit v1.2.3