Repository navigation
Description
Summary
The content.filter is not a function TypeError has been partially fixed upstream in pi-agent-core/dist/agent-loop.js and pi-coding-agent/dist/core/export-html/template.js (both now have Array.isArray() guards). However, the dist bundle dist/export-html/template.js still lacks this guard, leaving the crash vector open.
Reproduction
In dist/export-html/template.js at the msg.content.filter() call site (line ~1477 in v2026.5.28), if msg.content is undefined, null, or a non-array value, the following crash occurs:
TypeError: msg.content.filter is not a function
Root Cause
The source files in pi-agent-core and pi-coding-agent packages were patched with Array.isArray() guards, but the bundled dist artifact dist/export-html/template.js was not regenerated with the same fix, or the bundle copies from an older unpatched source.
Suggested Fix
Apply the same Array.isArray() guard pattern used in pi-coding-agent/dist/core/export-html/template.js:
// Before (vulnerable):
msg.content.filter((c) => c.type === "toolCall")
// After (safe):
(Array.isArray(msg.content) ? msg.content : []).filter((c) => c.type === "toolCall")Environment
- OpenClaw version: 2026.5.28 (67ddc1a)
- File:
dist/export-html/template.js(line ~1477) - Related: fix(agents): deduplicate user messages from model-fallback retries #52903 (duplicate user messages on fallback retry — same crash class)
Workaround
Users can manually patch the dist bundle file or use the community safe-upgrade script that applies this guard automatically.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon May 30, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed May 30, 2026, 2:22 AM ET / 06:22 UTC.
Summary
Keep open. Current main and v2026.5.27 still call
msg.content.filterin the export HTML template after accepting message rows without validatingmessage.content, so the reported export viewer crash remains a real source bug.Reproducibility: yes. at source level: a transcript message row with an assistant role but non-array or missing content passes export parsing and reaches
msg.content.filterin the template stats path. I did not run the browser template in this read-only review.Next step
This is a safe focused repair candidate, but not an automatic strict-bug lane because the review established source-level reproduction rather than a live current-main browser run.
Review details
Best possible solution:
Normalize message and tool-result content before every template filter/iteration path, add a regression render test for malformed assistant content, and let the build copy step regenerate the dist bundle from source.
Do we have a high-confidence way to reproduce the issue?
Yes at source level: a transcript message row with an assistant role but non-array or missing content passes export parsing and reaches
msg.content.filterin the template stats path. I did not run the browser template in this read-only review.Is this the best way to solve the issue?
Yes, the maintainable fix is to update the source export template and regression tests, not only patch a generated dist artifact. The repair should audit sibling content access sites so the malformed-message class is fixed consistently.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
msg.contentiteration and filtering paths in the same template vulnerable to the same malformed transcript shape.Codex review notes: model gpt-5.5, reasoning high; reviewed against 5aa2bd792124.
Label changes
Label changes:
P2: This is a normal-priority export viewer crash with a clear source path and limited blast radius.impact:other: The concrete impact is a broken exported-session HTML viewer, which is maintainer-visible but outside the specific owned impact categories.issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.clawsweeper:source-repro: Current issue advisory state selects this label.clawsweeper:queueable-fix: Current issue advisory state selects this label.clawsweeper:fix-shape-clear: Current issue advisory state selects this label.Label justifications:
P2: This is a normal-priority export viewer crash with a clear source path and limited blast radius.impact:other: The concrete impact is a broken exported-session HTML viewer, which is maintainer-visible but outside the specific owned impact categories.Evidence reviewed
Acceptance criteria:
What I checked:
computeStats()still doesmsg.content.filter((c) => c.type === "toolCall")for assistant messages, which will throw when a parsed transcript has missing, null, string, or otherwise non-array content. (src/auto-reply/reply/export-html/template.js:1477, 5aa2bd792124)message.roleis a string and does not validatemessage.content, then passes those entries into HTML generation after migration. (src/auto-reply/reply/commands-export-session.ts:168, 5aa2bd792124)msg.content.filtercall, so the issue is not already fixed in the shipped release. (src/auto-reply/reply/export-html/template.js:1477, 27ae826f6525)src/auto-reply/reply/export-htmlintodist/auto-reply/reply/export-html, so the durable fix belongs in the source template and its tests rather than only a hand-edited dist artifact. (scripts/build-all.mjs:84, 5aa2bd792124)git log -Sshows the unguarded stats filter carried through v2026.5.27 and current main. (src/auto-reply/reply/export-html/template.js:1477, f70b3a2e6878)Likely related people:
computeStats()included the unguarded tool-call filter. (role: introduced behavior; confidence: high; commits: f70b3a2e6878, add3afb7439e; files:src/auto-reply/reply/export-html/template.js,scripts/copy-export-html-templates.ts,src/auto-reply/reply/commands-export-session.ts)src/auto-reply/reply/export-html/template.js,scripts/copy-export-html-templates.ts)src/auto-reply/reply/export-html/template.js)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.fix(export-html): guard all msg.content and result.content filter/ite…
fix(export-html): guard msg.content and result.content filter/iterati…
steipete commentedon May 30, 2026
Fixed by PR #88271, landed as
5811693c7fce16f9780b904eb9159378f48734ec.Proof: targeted export-html security tests passed 13/13 with
node scripts/run-vitest.mjs src/auto-reply/reply/export-html/template.security.test.ts; autoreview was clean; changed-path scan, security scans, lint/types/build, and auto-reply CI shards passed on the PR head. The remaining broad CI failures were unrelated Vitest no-output watchdog timeouts in doctor/infra shards.fix(export-html): guard msg.content and result.content filter/iterati…
fix(export-html): guard msg.content and result.content filter/iterati…