openclaw - ✅(Solved) Fix Slack: Cannot read properties of undefined (reading 'includes') when sending replies [2 pull requests, 2 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#50060Fetched 2026-04-08 00:59:40
View on GitHub
Comments
2
Participants
2
Timeline
4
Reactions
0
Timeline (top)
commented ×2cross-referenced ×2

Error Message

This error is sent back to the user as a Slack message, making the bot unusable.

  • Similar issue #43163 (cron trim error)

Root Cause

The functions escapeSlackMrkdwnContent() and escapeSlackMrkdwnText() call text.includes() without null-safety checks. When the text is undefined (e.g., messages with attachments but no text body, or certain Slack event types), the code throws a TypeError.

Additionally, payload.text.includes("[[") in the deliver files can crash when payload.text is undefined.

Fix Action

Fixed

PR fix notes

PR #52785: fix: ignore non-string mention patterns during mention gating

Description (problem / solution / changelog)

Summary

  • harden mention pattern normalization to ignore non-string messages.groupChat.mentionPatterns entries before .includes-based normalization
  • add a regression test covering mixed valid/invalid mention pattern entries and note the behavior in CHANGELOG.md
  • open as a draft because this is still a hypothesis fix for #50060; the issue's quoted stack does not cleanly match the current or tagged source code we verified

Why

The reported Slack crash is Cannot read properties of undefined (reading 'includes') during mention-triggered handling. While the exact stack in #50060 does not match the current repo source, mention gating still had one realistic .includes risk: normalizeMentionPattern() assumed every configured mention pattern was a string. This patch makes that path robust by dropping invalid entries instead of crashing the gating pipeline.

Evidence gathered

  • verified the currently cited paths in the issue are already guarded in source/tagged code:
    • extensions/slack/src/format.ts
    • src/auto-reply/reply/reply-payloads.ts
    • src/utils/directive-tags.ts
  • verified 2026.3.13-1 also already guards the issue's quoted .includes sites
  • issue file names like extensionAPI.js / loader-*.js do not map cleanly to this repo tree, so there may be a packaged-artifact or misreported-stack mismatch

Testing

  • AI-assisted PR
  • Lightly tested
  • Fully tested
  • I understand what the code does
  • Prompts/session logs included

Commands run:

Known blockers / caveats

  • targeted inbound test file already has unrelated failures around provider mention stripping / requireMention behavior
  • Slack extension lane currently has unrelated pre-existing failures from missing exports in plugin-sdk test mocks
  • a workspace dependency prepare step emitted unrelated type errors during install, but dependency installation completed and the repo test commands were runnable afterward
  • this draft should stay in draft until we confirm the production stack or decide this hardening is still worth merging independently

Closes #50060

Changed files

  • .agents/skills/openclaw-ghsa-maintainer/SKILL.md (removed, +0/-87)
  • .agents/skills/openclaw-parallels-smoke/SKILL.md (removed, +0/-72)
  • .agents/skills/openclaw-pr-maintainer/SKILL.md (removed, +0/-75)
  • .agents/skills/openclaw-release-maintainer/SKILL.md (removed, +0/-74)
  • .agents/skills/openclaw-test-heap-leaks/SKILL.md (removed, +0/-71)
  • .agents/skills/openclaw-test-heap-leaks/agents/openai.yaml (removed, +0/-4)
  • .agents/skills/openclaw-test-heap-leaks/scripts/heapsnapshot-delta.mjs (removed, +0/-265)
  • .agents/skills/security-triage/SKILL.md (removed, +0/-108)
  • .dockerignore (modified, +1/-1)
  • .github/ISSUE_TEMPLATE/bug_report.yml (modified, +25/-21)
  • .github/actions/ensure-base-commit/action.yml (modified, +2/-6)
  • .github/actions/setup-node-env/action.yml (modified, +1/-1)
  • .github/labeler.yml (modified, +0/-11)
  • .github/pull_request_template.md (modified, +1/-1)
  • .github/workflows/auto-response.yml (modified, +1/-3)
  • .github/workflows/ci.yml (modified, +449/-263)
  • .github/workflows/codeql.yml (modified, +1/-1)
  • .github/workflows/docker-release.yml (modified, +1/-9)
  • .github/workflows/install-smoke.yml (modified, +16/-98)
  • .github/workflows/openclaw-npm-release.yml (modified, +1/-1)
  • .github/workflows/sandbox-common-smoke.yml (modified, +0/-2)
  • .github/workflows/stale.yml (modified, +2/-2)
  • .github/workflows/workflow-sanity.yml (modified, +1/-7)
  • .gitignore (modified, +2/-1)
  • AGENTS.md (modified, +158/-50)
  • CHANGELOG.md (modified, +1/-0)
  • CONTRIBUTING.md (modified, +2/-5)
  • Dockerfile (modified, +1/-11)
  • README.md (modified, +2/-2)
  • apps/android/README.md (modified, +4/-66)
  • apps/android/app/build.gradle.kts (modified, +4/-24)
  • apps/android/app/src/main/AndroidManifest.xml (modified, +0/-1)
  • apps/android/app/src/main/java/ai/openclaw/app/MainViewModel.kt (modified, +1/-11)
  • apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt (modified, +40/-57)
  • apps/android/app/src/main/java/ai/openclaw/app/PermissionRequester.kt (modified, +21/-79)
  • apps/android/app/src/main/java/ai/openclaw/app/chat/ChatController.kt (modified, +6/-10)
  • apps/android/app/src/main/java/ai/openclaw/app/node/A2UIHandler.kt (modified, +0/-7)
  • apps/android/app/src/main/java/ai/openclaw/app/node/CameraCaptureManager.kt (modified, +30/-36)
  • apps/android/app/src/main/java/ai/openclaw/app/node/CameraHandler.kt (modified, +3/-5)
  • apps/android/app/src/main/java/ai/openclaw/app/node/CanvasActionTrust.kt (removed, +0/-50)
  • apps/android/app/src/main/java/ai/openclaw/app/node/CanvasController.kt (modified, +14/-28)
  • apps/android/app/src/main/java/ai/openclaw/app/node/ConnectionManager.kt (modified, +2/-6)
  • apps/android/app/src/main/java/ai/openclaw/app/node/ContactsHandler.kt (modified, +2/-5)
  • apps/android/app/src/main/java/ai/openclaw/app/node/DeviceHandler.kt (modified, +4/-6)
  • apps/android/app/src/main/java/ai/openclaw/app/node/InvokeCommandRegistry.kt (modified, +6/-22)
  • apps/android/app/src/main/java/ai/openclaw/app/node/InvokeDispatcher.kt (modified, +3/-24)
  • apps/android/app/src/main/java/ai/openclaw/app/node/LocationCaptureManager.kt (modified, +9/-4)
  • apps/android/app/src/main/java/ai/openclaw/app/node/LocationHandler.kt (modified, +17/-75)
  • apps/android/app/src/main/java/ai/openclaw/app/node/MotionHandler.kt (modified, +18/-14)
  • apps/android/app/src/main/java/ai/openclaw/app/node/PhotosHandler.kt (modified, +34/-49)
  • apps/android/app/src/main/java/ai/openclaw/app/node/SmsHandler.kt (modified, +0/-12)
  • apps/android/app/src/main/java/ai/openclaw/app/node/SmsManager.kt (modified, +1/-384)
  • apps/android/app/src/main/java/ai/openclaw/app/protocol/OpenClawCanvasA2UIAction.kt (modified, +3/-6)
  • apps/android/app/src/main/java/ai/openclaw/app/protocol/OpenClawProtocolConstants.kt (modified, +0/-1)
  • apps/android/app/src/main/java/ai/openclaw/app/ui/CanvasScreen.kt (modified, +3/-34)
  • apps/android/app/src/main/java/ai/openclaw/app/ui/ConnectTabScreen.kt (modified, +2/-46)
  • apps/android/app/src/main/java/ai/openclaw/app/ui/GatewayConfigResolver.kt (modified, +2/-19)
  • apps/android/app/src/main/java/ai/openclaw/app/ui/GatewayDiagnostics.kt (removed, +0/-77)
  • apps/android/app/src/main/java/ai/openclaw/app/ui/OnboardingFlow.kt (modified, +30/-112)
  • apps/android/app/src/main/java/ai/openclaw/app/ui/OpenClawTheme.kt (modified, +0/-13)
  • apps/android/app/src/main/java/ai/openclaw/app/ui/PostOnboardingTabs.kt (modified, +8/-46)
  • apps/android/app/src/main/java/ai/openclaw/app/ui/SettingsSheet.kt (modified, +30/-40)
  • apps/android/app/src/main/java/ai/openclaw/app/ui/chat/ChatSheetContent.kt (modified, +1/-0)
  • apps/android/app/src/main/java/ai/openclaw/app/voice/ElevenLabsStreamingTts.kt (added, +338/-0)
  • apps/android/app/src/main/java/ai/openclaw/app/voice/StreamingMediaDataSource.kt (added, +98/-0)
  • apps/android/app/src/main/java/ai/openclaw/app/voice/TalkModeGatewayConfig.kt (modified, +115/-4)
  • apps/android/app/src/main/java/ai/openclaw/app/voice/TalkModeManager.kt (modified, +844/-126)
  • apps/android/app/src/main/java/ai/openclaw/app/voice/TalkModeVoiceResolver.kt (added, +122/-0)
  • apps/android/app/src/play/AndroidManifest.xml (removed, +0/-13)
  • apps/android/app/src/test/java/ai/openclaw/app/node/CanvasActionTrustTest.kt (removed, +0/-42)
  • apps/android/app/src/test/java/ai/openclaw/app/node/InvokeCommandRegistryTest.kt (modified, +7/-64)
  • apps/android/app/src/test/java/ai/openclaw/app/node/LocationHandlerTest.kt (removed, +0/-88)
  • apps/android/app/src/test/java/ai/openclaw/app/node/SmsManagerTest.kt (modified, +0/-91)
  • apps/android/app/src/test/java/ai/openclaw/app/protocol/OpenClawCanvasA2UIActionTest.kt (modified, +0/-14)
  • apps/android/app/src/test/java/ai/openclaw/app/protocol/OpenClawProtocolConstantsTest.kt (modified, +0/-5)
  • apps/android/app/src/test/java/ai/openclaw/app/ui/GatewayConfigResolverTest.kt (modified, +0/-78)
  • apps/android/app/src/test/java/ai/openclaw/app/voice/TalkModeConfigContractTest.kt (added, +100/-0)
  • apps/android/app/src/test/java/ai/openclaw/app/voice/TalkModeConfigParsingTest.kt (modified, +109/-11)
  • apps/android/app/src/test/java/ai/openclaw/app/voice/TalkModeVoiceResolverTest.kt (added, +92/-0)
  • apps/android/build.gradle.kts (modified, +2/-2)
  • apps/android/gradle/wrapper/gradle-wrapper.properties (modified, +1/-1)
  • apps/android/scripts/build-release-aab.ts (modified, +10/-44)
  • apps/android/scripts/perf-online-benchmark.sh (removed, +0/-430)
  • apps/ios/Config/Version.xcconfig (modified, +3/-3)
  • apps/ios/README.md (modified, +3/-3)
  • apps/ios/Sources/Gateway/GatewayConnectionController.swift (modified, +1/-6)
  • apps/ios/Sources/Onboarding/OnboardingWizardView.swift (modified, +1/-7)
  • apps/ios/fastlane/Fastfile (modified, +1/-1)
  • apps/macos/Sources/OpenClaw/AppState.swift (modified, +2/-2)
  • apps/macos/Sources/OpenClaw/CanvasA2UIActionMessageHandler.swift (modified, +2/-2)
  • apps/macos/Sources/OpenClaw/CanvasWindowController.swift (modified, +2/-1)
  • apps/macos/Sources/OpenClaw/CronJobEditor+Helpers.swift (modified, +3/-6)
  • apps/macos/Sources/OpenClaw/CronModels.swift (modified, +13/-13)
  • apps/macos/Sources/OpenClaw/ExecApprovalCommandDisplaySanitizer.swift (removed, +0/-31)
  • apps/macos/Sources/OpenClaw/ExecApprovalEvaluation.swift (modified, +1/-10)
  • apps/macos/Sources/OpenClaw/ExecApprovalsGatewayPrompter.swift (modified, +7/-7)
  • apps/macos/Sources/OpenClaw/ExecApprovalsSocket.swift (modified, +9/-3)
  • apps/macos/Sources/OpenClaw/ExecCommandResolution.swift (modified, +2/-158)
  • apps/macos/Sources/OpenClaw/ExecEnvInvocationUnwrapper.swift (modified, +2/-66)
  • apps/macos/Sources/OpenClaw/ExecHostRequestEvaluator.swift (modified, +1/-5)

PR #52895: fix: ignore non-string mention patterns during mention gating

Description (problem / solution / changelog)

Summary

  • ignore non-string messages.groupChat.mentionPatterns entries before mention-pattern normalization runs .includes-based escaping
  • add a regression test that proves invalid entries are dropped while the valid pattern still compiles
  • add a changelog note for the mention-gating hardening

Why

This PR is recreated from a fresh clean branch because the previous PR picked up dirty history and stale merge metadata. The code diff here is intentionally minimal: three files only, on top of current main.

Testing

  • AI-assisted PR
  • Lightly tested
  • Fully tested
  • I understand what the code does
  • Prompts/session logs included

Commands run:

  • pnpm check
  • npx [email protected] test -- --run src/auto-reply/inbound.test.ts -t "ignores non-string mention patterns"
  • npx [email protected] test -- --run src/auto-reply/inbound.test.ts ⚠️ 2 pre-existing unrelated failures in resolveGroupRequireMention expectations for Discord/Slack

Notes

  • This PR replaces the earlier dirty PR and is based on current origin/main.
  • Current diff against main is limited to:
    • src/auto-reply/reply/mentions.ts
    • src/auto-reply/inbound.test.ts
    • CHANGELOG.md

Closes #50060

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • src/auto-reply/inbound.test.ts (modified, +92/-1)
  • src/auto-reply/reply/mentions.ts (modified, +83/-10)

Code Example

Cannot read properties of undefined (reading 'includes')

---

// Before
if (text.includes("<")) { ... }

// After  
if (text?.includes("<")) { ... }

// Also for deliver files
if (payload.text?.includes("[[")) { ... }
RAW_BUFFERClick to expand / collapse

Bug Description

When the Slack bot tries to reply to a message, it crashes with:

Cannot read properties of undefined (reading 'includes')

This error is sent back to the user as a Slack message, making the bot unusable.

Root Cause

The functions escapeSlackMrkdwnContent() and escapeSlackMrkdwnText() call text.includes() without null-safety checks. When the text is undefined (e.g., messages with attachments but no text body, or certain Slack event types), the code throws a TypeError.

Additionally, payload.text.includes("[[") in the deliver files can crash when payload.text is undefined.

Files Affected

  1. extensionAPI.js - escapeSlackMrkdwnContent + escapeSlackMrkdwnText
  2. loader-*.js - same functions
  3. pi-embedded-*.js - same functions
  4. reply-*.js - same functions
  5. deliver-*.js - payload.text.includes("[[")

Suggested Fix

Add optional chaining:

// Before
if (text.includes("<")) { ... }

// After  
if (text?.includes("<")) { ... }

// Also for deliver files
if (payload.text?.includes("[[")) { ... }

Environment

  • OpenClaw 2026.3.13
  • Slack channel plugin (stock)

Related

  • Similar issue #49094 (WhatsApp peer.js has same pattern)
  • Similar issue #43163 (cron trim error)

extent analysis

Fix Plan

To resolve the issue, we need to add null-safety checks using optional chaining to the affected functions. Here are the concrete steps:

  • In extensionAPI.js, loader-*.js, pi-embedded-*.js, and reply-*.js, update the escapeSlackMrkdwnContent() and escapeSlackMrkdwnText() functions to use optional chaining:
// Before
if (text.includes("<")) { 
  // ...
}

// After
if (text?.includes("<")) { 
  // ...
}
  • In deliver-*.js, update the payload.text.includes("[[") line to use optional chaining:
// Before
if (payload.text.includes("[[")) { 
  // ...
}

// After
if (payload.text?.includes("[[")) { 
  // ...
}

Verification

To verify that the fix worked, test the Slack bot by sending messages with and without text bodies, as well as messages with attachments. The bot should no longer crash and should respond correctly.

Extra Tips

  • Make sure to update all instances of the affected functions in the specified files.
  • Consider adding additional null-safety checks to other parts of the codebase to prevent similar issues in the future.
  • Review similar issues (#49094 and #43163) to ensure that the same pattern is not present in other parts of the codebase.

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