openclaw - ✅(Solved) Fix Telegram dispatch crash: hashText(undefined).trim() on group chat follow-up messages [1 pull requests, 1 participants]

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…
GitHub stats
openclaw/openclaw#59066Fetched 2026-04-08 02:29:09
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Participants

Error Message

[telegram] dispatch failed: TypeError: Cannot read properties of undefined (reading 'trim')

Fix Action

Workaround

None found. Clearing sessions does not help since the crash occurs during dispatch before session persistence.

PR fix notes

PR #65567: fix(telegram): guard hashText against undefined text in dispatch

Description (problem / solution / changelog)

Summary

Telegram group chat follow-up messages crash with TypeError: Cannot read properties of undefined (reading 'trim') when event.text is undefined during dispatch.

Problem

In acp-projector.ts, the usage_update status handler falls back to hashText(event.text) when event.used/event.size are not numbers. hashText calls .trim() directly on its argument, which crashes when event.text is undefined. This happens on follow-up messages in group chats bound to non-default agents.

The first message in a session works; subsequent messages crash because the status event structure differs.

Fix

Accept undefined in hashText and fall back to empty string: (text ?? "").trim().

Test plan

  • All 22 acp-projector tests pass

Closes #59066

Changed files

  • src/auto-reply/reply/acp-projector.ts (modified, +3/-3)

Code Example

[telegram] dispatch failed: TypeError: Cannot read properties of undefined (reading 'trim')

---

function hashText(text) { return text.trim(); }

---

{
  "id": "pmm3-manager",
  "name": "PMM3 Research Group Agent",
  "model": {
    "primary": "github-copilot/gpt-5-mini",
    "fallbacks": ["google/gemini-2.5-flash", "google/gemini-3-flash-preview"]
  },
  "workspace": "/data/.openclaw/workspace-pmm3",
  "sandbox": { "mode": "off" },
  "groupChat": {
    "mentionPatterns": ["ая", "айона", "aya", "ayona", "@ayona_pmm_bot"],
    "historyLimit": 20
  }
}

---

{
  "agentId": "pmm3-manager",
  "match": {
    "channel": "telegram",
    "accountId": "pmm3-manager",
    "peer": { "kind": "group", "id": "-1003766168686" }
  }
}

---

function hashText(text) { return (text ?? "").trim(); }
RAW_BUFFERClick to expand / collapse

Bug Description

Telegram dispatch crashes with TypeError: Cannot read properties of undefined (reading 'trim') when processing follow-up messages in group chats bound to a non-default agent. The first message in a session works correctly; subsequent messages in the same session crash.

Environment

  • OpenClaw version: 2026.3.28 (f9b1079)
  • Hosting: Hostinger VPS, Docker container
  • Node.js: v25.7.0
  • Channel: Telegram group chat
  • Agent: Non-default agent with dedicated workspace and Telegram account binding

Reproduction Steps

  1. Configure a secondary agent (e.g., pmm3-manager) with:

    • Own Telegram bot account
    • Group chat binding via bindings[]
    • groupChat.mentionPatterns for @mention detection
    • Sandbox mode: off (also reproduces with sandbox enabled)
  2. Send a message mentioning the bot in the bound group → first response works

  3. Reply to the bot's response in the same group → crash:

    [telegram] dispatch failed: TypeError: Cannot read properties of undefined (reading 'trim')

    User sees: "Something went wrong while processing your request. Please try again."

Error Location

From the file log, the error originates in dispatch-acp.runtime (compiled bundle). The crash is in:

function hashText(text) { return text.trim(); }

hashText is called with undefined — likely from a tool call result or session history entry where text is not set.

Agent Configuration (relevant parts)

{
  "id": "pmm3-manager",
  "name": "PMM3 Research Group Agent",
  "model": {
    "primary": "github-copilot/gpt-5-mini",
    "fallbacks": ["google/gemini-2.5-flash", "google/gemini-3-flash-preview"]
  },
  "workspace": "/data/.openclaw/workspace-pmm3",
  "sandbox": { "mode": "off" },
  "groupChat": {
    "mentionPatterns": ["ая", "айона", "aya", "ayona", "@ayona_pmm_bot"],
    "historyLimit": 20
  }
}

Binding:

{
  "agentId": "pmm3-manager",
  "match": {
    "channel": "telegram",
    "accountId": "pmm3-manager",
    "peer": { "kind": "group", "id": "-1003766168686" }
  }
}

Key Observations

  • First message in a new session works (bot responds with tool calls like web_fetch, read)
  • Follow-up message in the same session crashes
  • Session store shows 0 messages after crash (messages not persisted)
  • The crash occurs regardless of sandbox mode (tested with mode: "all" and mode: "off")
  • Default agent (main) in DM does not exhibit this bug

Suggested Fix

Guard hashText against undefined input:

function hashText(text) { return (text ?? "").trim(); }

Or add a null check at the call site before invoking hashText.

Workaround

None found. Clearing sessions does not help since the crash occurs during dispatch before session persistence.

extent analysis

TL;DR

Guarding the hashText function against undefined input is likely to fix the crash issue.

Guidance

  • Verify that the hashText function is indeed the source of the error by checking the file log and the compiled bundle dispatch-acp.runtime.
  • Apply the suggested fix by modifying the hashText function to guard against undefined input, using the nullish coalescing operator (??) or a null check.
  • Test the fix by sending a follow-up message in the same group chat session to ensure the crash no longer occurs.
  • If the issue persists, investigate the session store and message persistence to ensure that messages are being stored correctly.

Example

function hashText(text) { return (text ?? "").trim(); }

This code snippet demonstrates how to guard the hashText function against undefined input using the nullish coalescing operator (??).

Notes

The suggested fix assumes that the hashText function is the sole source of the error. If the issue persists after applying the fix, further investigation into the session store and message persistence may be necessary.

Recommendation

Apply the suggested fix by modifying the hashText function to guard against undefined input, as it is a targeted and minimal change that addresses the identified issue.

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