openclaw - ✅(Solved) Fix TypeError: Cannot read properties of undefined (reading 'trim') on Feishu group messages with empty content [4 pull requests, 1 comments, 2 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#66657Fetched 2026-04-15 06:25:08
View on GitHub
Comments
1
Participants
2
Timeline
10
Reactions
1
Author
Participants
Timeline (top)
cross-referenced ×4referenced ×2subscribed ×2commented ×1

When a user sends a Feishu group message that contains only an @mention (no text body), or certain other message types with empty/undefined content, the bot fails to dispatch the message and throws a TypeError.

Error Message

feishu[<account>]: failed to dispatch message: TypeError: Cannot read properties of undefined (reading 'trim')

Root Cause

Two locations call .content.trim() on the result of parseFeishuMessageEvent() without null-checking content:

  1. extensions/feishu/src/sequential-key.tsgetFeishuSequentialKey():

    const text = parseFeishuMessageEvent(event, botOpenId, botName).content.trim();
  2. extensions/feishu/src/sequential-queue.tsresolveDebounceText():

    return parseFeishuMessageEvent(event, botOpenIds.get(accountId), botNames.get(accountId)).content.trim();

When event.message.content is undefined (e.g. pure @mention with no text), parseMessageContent() returns undefined, normalizeMentions() passes it through, and .trim() throws.

Fix Action

Fix / Workaround

When a user sends a Feishu group message that contains only an @mention (no text body), or certain other message types with empty/undefined content, the bot fails to dispatch the message and throws a TypeError.

feishu[<account>]: failed to dispatch message: TypeError: Cannot read properties of undefined (reading 'trim')

PR fix notes

PR #8: fix(feishu): handle undefined content in @mention-only messages

Description (problem / solution / changelog)

Summary

Fix TypeError when Feishu group messages contain only an @mention with no text body. The parseFeishuMessageEvent() result can have undefined content, causing .trim() to throw.

Changes

  • extensions/feishu/src/sequential-key.ts: Add optional chaining ?.trim() ?? "" to guard against undefined content
  • extensions/feishu/src/monitor.account.ts: Same fix for resolveDebounceText()
  • Added test case for empty content (pure @mention)

Test coverage

  • All existing Feishu tests pass (129 tests)
  • Added new test: does not throw when message content is undefined (pure @mention with no text)

Fixes #66657

Changed files

  • extensions/feishu/src/monitor.account.ts (modified, +1/-1)
  • extensions/feishu/src/sequential-key.test.ts (modified, +20/-0)
  • extensions/feishu/src/sequential-key.ts (modified, +1/-1)
  • extensions/qqbot/src/gateway.ts (modified, +1/-1)
  • extensions/qqbot/src/utils/text-parsing.test.ts (modified, +4/-0)
  • extensions/qqbot/src/utils/text-parsing.ts (modified, +2/-2)
  • package.json (modified, +2/-7)
  • scripts/openclaw-npm-release-check.ts (modified, +4/-6)
  • src/memory-host-sdk/host/embeddings.ts (modified, +1/-1)

PR #66698: fix(feishu): handle undefined content in @mention-only messages

Description (problem / solution / changelog)

Summary

Fix TypeError when Feishu group messages contain only an @mention with no text body.

Changes

  • extensions/feishu/src/sequential-key.ts: Add optional chaining ?.trim() ?? "" to guard against undefined content
  • extensions/feishu/src/monitor.account.ts: Same fix for resolveDebounceText()
  • Added test case for empty content (pure @mention)

Test coverage

  • All 129 Feishu tests pass (7 sequential-key tests including new test)

Fixes #66657

Changed files

  • extensions/feishu/src/monitor.account.ts (modified, +1/-1)
  • extensions/feishu/src/sequential-key.test.ts (modified, +20/-0)
  • extensions/feishu/src/sequential-key.ts (modified, +1/-1)
  • extensions/qqbot/src/gateway.ts (modified, +1/-1)
  • extensions/qqbot/src/utils/text-parsing.test.ts (modified, +4/-0)
  • extensions/qqbot/src/utils/text-parsing.ts (modified, +2/-2)
  • package.json (modified, +2/-7)
  • scripts/openclaw-npm-release-check.ts (modified, +4/-6)
  • src/memory-host-sdk/host/embeddings.ts (modified, +1/-1)

PR #66725: fix(feishu): handle undefined content in @mention-only messages

Description (problem / solution / changelog)

Summary

Fix TypeError when Feishu group messages contain only an @mention with no text body.

Root Cause

parseFeishuMessageEvent() can return an object with undefined content when the message contains only an @mention (no text). Calling .trim() on undefined throws:

TypeError: Cannot read properties of undefined (reading 'trim')

Fix

Added optional chaining .content?.trim() ?? "" at two locations:

  • extensions/feishu/src/sequential-key.tsgetFeishuSequentialKey()
  • extensions/feishu/src/monitor.account.tsresolveDebounceText()

Testing

  • Added sequential-key.test.ts test case covering @mention-only messages with empty content
  • All 7 tests in sequential-key.test.ts pass

Fixes #66657

Changed files

  • extensions/qqbot/src/utils/text-parsing.test.ts (modified, +4/-0)
  • extensions/qqbot/src/utils/text-parsing.ts (modified, +2/-2)

PR #67137: fix: prevent trim error when skipping optional input during channel selection

Description (problem / solution / changelog)

Summary

  • Problem: the onboarding/channel setup flow could crash with TypeError: Cannot read properties of undefined (reading 'trim') when a setup text prompt yielded undefined and downstream code assumed it was always a string.
  • Why it matters: this breaks real onboarding paths and can stop users from finishing setup.
  • What changed: normalize text prompt results before trimming at the prompt/setup boundary, and add regression tests covering the undefined prompt-result path.
  • What did NOT change (scope boundary): this PR does not change required-field validation, channel semantics, or unrelated wizard behavior.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #66945
  • Related #66657, #66677, #66693, #66718, #66942
  • This PR fixes a bug or regression

Root Cause (if applicable)

  • Root cause: parts of the setup flow assumed prompter.text(...) always returned a string and called .trim() directly on the result.
  • Missing detection / guardrail: there was no normalization guard for undefined text prompt results, and no regression test covering that path.
  • Contributing context (if known): setup flows include skip/secret-input paths where the prompt layer can surface an empty or undefined-like result, but downstream code still treated the value as a guaranteed string.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file:
    • src/channels/plugins/setup-wizard-helpers.test.ts
    • src/wizard/clack-prompter.test.ts
  • Scenario the test should lock in: when the text prompter yields undefined, setup flow helpers normalize it safely instead of crashing on .trim().
  • Why this is the smallest reliable guardrail: the failure comes from a local string-assumption at the prompt/setup boundary, so unit coverage there is the narrowest test that directly protects the bug.
  • Existing test that already covers this (if any): none that covered the undefined prompt-result path.
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

  • Onboarding/channel setup no longer crashes with TypeError: Cannot read properties of undefined (reading 'trim') when a setup text prompt yields undefined.
  • Required-field validation behavior remains unchanged.

Diagram (if applicable)

Before:
[setup text prompt yields undefined]
  -> [.trim() is called on undefined]
  -> [wizard crashes]

After:
[setup text prompt yields undefined]
  -> [value is normalized first]
  -> [wizard continues safely]

## Changed files

- `src/channels/plugins/setup-wizard-helpers.test.ts` (modified, +19/-0)
- `src/channels/plugins/setup-wizard-helpers.ts` (modified, +3/-3)
- `src/channels/plugins/setup-wizard.ts` (modified, +1/-1)
- `src/wizard/clack-prompter.test.ts` (modified, +33/-2)
- `src/wizard/clack-prompter.ts` (modified, +2/-1)

Code Example

feishu[<account>]: failed to dispatch message: TypeError: Cannot read properties of undefined (reading 'trim')

---

const text = parseFeishuMessageEvent(event, botOpenId, botName).content.trim();

---

return parseFeishuMessageEvent(event, botOpenIds.get(accountId), botNames.get(accountId)).content.trim();

---

// sequential-key.ts
const text = parseFeishuMessageEvent(event, botOpenId, botName).content?.trim() || "";

// sequential-queue.ts
return parseFeishuMessageEvent(event, botOpenIds.get(accountId), botNames.get(accountId)).content?.trim() || "";
RAW_BUFFERClick to expand / collapse

Description

When a user sends a Feishu group message that contains only an @mention (no text body), or certain other message types with empty/undefined content, the bot fails to dispatch the message and throws a TypeError.

Error Log

feishu[<account>]: failed to dispatch message: TypeError: Cannot read properties of undefined (reading 'trim')

Root Cause

Two locations call .content.trim() on the result of parseFeishuMessageEvent() without null-checking content:

  1. extensions/feishu/src/sequential-key.tsgetFeishuSequentialKey():

    const text = parseFeishuMessageEvent(event, botOpenId, botName).content.trim();
  2. extensions/feishu/src/sequential-queue.tsresolveDebounceText():

    return parseFeishuMessageEvent(event, botOpenIds.get(accountId), botNames.get(accountId)).content.trim();

When event.message.content is undefined (e.g. pure @mention with no text), parseMessageContent() returns undefined, normalizeMentions() passes it through, and .trim() throws.

Suggested Fix

Use optional chaining at both locations:

// sequential-key.ts
const text = parseFeishuMessageEvent(event, botOpenId, botName).content?.trim() || "";

// sequential-queue.ts
return parseFeishuMessageEvent(event, botOpenIds.get(accountId), botNames.get(accountId)).content?.trim() || "";

Environment

  • openclaw version: 2026.4.12
  • Channel: Feishu
  • Message type: group chat, triggered by @mention with empty text body

Reproduction Steps

  1. Add a bot to a Feishu group chat
  2. Send a message that is only @botname with no additional text
  3. Observe the error in logs and no response from the bot

extent analysis

TL;DR

Apply optional chaining to prevent TypeError when handling messages with empty or undefined content.

Guidance

  • Verify that parseFeishuMessageEvent() returns undefined for messages with empty content by adding a null check before calling .trim().
  • Update the code in sequential-key.ts and sequential-queue.ts to use optional chaining (?.) when accessing the content property.
  • Test the fix by reproducing the error using the provided reproduction steps and verifying that the bot no longer throws a TypeError.
  • Consider adding additional logging or error handling to handle cases where content is undefined or null.

Example

const text = parseFeishuMessageEvent(event, botOpenId, botName).content?.trim() || "";

Notes

This fix assumes that an empty string is a valid default value when content is undefined. If a different default value is required, the || operator can be updated accordingly.

Recommendation

Apply the suggested fix using optional chaining to prevent the TypeError and ensure the bot can handle messages with empty or undefined content.

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