openclaw - 💡(How to fix) Fix Bug: dist/export-html/template.js content.filter crash — missing Array.isArray guard in dist bundle

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

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.

Error Message

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.

Fix Action

Workaround

Users can manually patch the dist bundle file or use the community safe-upgrade script that applies this guard automatically.

Code Example

TypeError: msg.content.filter is not a function

---

// Before (vulnerable):
msg.content.filter((c) => c.type === "toolCall")

// After (safe):
(Array.isArray(msg.content) ? msg.content : []).filter((c) => c.type === "toolCall")
RAW_BUFFERClick to expand / collapse

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: #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.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Bug: dist/export-html/template.js content.filter crash — missing Array.isArray guard in dist bundle