Skip to content

fix(bluebubbles): guard debounce flush against null text#56573

Merged
hydro13 merged 1 commit intoopenclaw:mainfrom
hydro13:fix/bluebubbles-null-text-crash
Mar 28, 2026
Merged

fix(bluebubbles): guard debounce flush against null text#56573
hydro13 merged 1 commit intoopenclaw:mainfrom
hydro13:fix/bluebubbles-null-text-crash

Conversation

@hydro13
Copy link
Copy Markdown
Member

@hydro13 hydro13 commented Mar 28, 2026

Summary

  • Sanitize message text at debounce enqueue boundary — coerce null/undefined to empty string
  • Add independent guard in combineDebounceEntries() for entries already queued
  • Prevents TypeError: Cannot read properties of null (reading 'trim') during debounce flush

Root Cause

combineDebounceEntries() in extensions/bluebubbles/src/monitor-debounce.ts:67 calls entry.message.text.trim() without null guard. When a webhook delivers a message with null text (e.g. tapback/reaction-only), the multi-entry flush path crashes.

Change Type

  • Bug fix

Testing

18 test suites, 363 tests pass. New regression test:

  • Enqueue null-text entry + valid entry with same messageId
  • Advance timers to force flush
  • Verify no error thrown
  • Verify valid message is delivered to processMessage

Fixes #35777

Sanitize message text at the debounce enqueue boundary and add an
independent guard in combineDebounceEntries(). Prevents TypeError when
a queued entry has null text that reaches .trim() during flush.

Add regression test: enqueue null-text entry alongside valid message,
verify flush completes without error and valid message is delivered.

Fixes openclaw#35777
@openclaw-barnacle openclaw-barnacle Bot added channel: bluebubbles Channel integration: bluebubbles size: M maintainer Maintainer-authored PR labels Mar 28, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 28, 2026

Greptile Summary

This PR fixes a TypeError: Cannot read properties of null (reading 'trim') crash in monitor-debounce.ts that occurred when BlueBubbles delivered a webhook message with null text (e.g., a tapback/reaction-only message) and that null-text entry ended up in the multi-entry combineDebounceEntries() flush path.

Changes:

  • Adds normalizeDebounceMessageText(text: unknown): string — a small helper that coerces any non-string to "", used as a guard inside combineDebounceEntries() before calling .trim().
  • Adds sanitizeDebounceEntry() — normalizes message.text to "" at the enqueue boundary, so entries stored in the debounce bucket are always well-formed before they can be flushed.
  • Wraps the raw baseDebouncer in a thin debouncer shim that calls sanitizeDebounceEntry on every enqueue, providing defence-in-depth.
  • Extracts the inline timing-aware debouncer test double into a reusable installTimingAwareInboundDebouncer helper, cleaning up a large block of duplicated test setup.
  • Adds a focused regression test that enqueues a null-text entry followed by a valid entry sharing the same messageId, advances fake timers to force a multi-entry flush, and asserts the valid text is delivered without error.

Confidence Score: 5/5

This PR is safe to merge — the fix is targeted, the defence-in-depth layering is sound, and the new regression test directly covers the crash path.

Both the enqueue-time sanitization and the in-loop guard in combineDebounceEntries are correct and do not change behaviour for well-formed messages. The null-text entry is quietly dropped from the combined text (matching the existing empty-string filter), while valid co-batched entries are still delivered. The regression test exercises the exact multi-entry flush path that was crashing. No P0 or P1 findings were identified.

No files require special attention.

Important Files Changed

Filename Overview
extensions/bluebubbles/src/monitor-debounce.ts Adds null-text sanitization at enqueue boundary and a normalizer guard inside combineDebounceEntries; wraps baseDebouncer in a thin shim — all changes are correct and non-breaking.
extensions/bluebubbles/src/monitor.test.ts Extracts reusable debouncer test-double helper and adds a targeted regression test covering the null-text multi-entry flush crash path.

Reviews (1): Last reviewed commit: "fix(bluebubbles): guard debounce flush a..." | Re-trigger Greptile

@hydro13 hydro13 merged commit e69ea1a into openclaw:main Mar 28, 2026
36 of 38 checks passed
hydro13 added a commit that referenced this pull request Mar 28, 2026
alexcode-cc pushed a commit to alexcode-cc/clawdbot that referenced this pull request Mar 30, 2026
)

Sanitize message text at the debounce enqueue boundary and add an
independent guard in combineDebounceEntries(). Prevents TypeError when
a queued entry has null text that reaches .trim() during flush.

Add regression test: enqueue null-text entry alongside valid message,
verify flush completes without error and valid message is delivered.

Fixes openclaw#35777
alexjiang1 pushed a commit to alexjiang1/openclaw that referenced this pull request Mar 31, 2026
)

Sanitize message text at the debounce enqueue boundary and add an
independent guard in combineDebounceEntries(). Prevents TypeError when
a queued entry has null text that reaches .trim() during flush.

Add regression test: enqueue null-text entry alongside valid message,
verify flush completes without error and valid message is delivered.

Fixes openclaw#35777
pgondhi987 pushed a commit to pgondhi987/openclaw that referenced this pull request Mar 31, 2026
)

Sanitize message text at the debounce enqueue boundary and add an
independent guard in combineDebounceEntries(). Prevents TypeError when
a queued entry has null text that reaches .trim() during flush.

Add regression test: enqueue null-text entry alongside valid message,
verify flush completes without error and valid message is delivered.

Fixes openclaw#35777
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
)

Sanitize message text at the debounce enqueue boundary and add an
independent guard in combineDebounceEntries(). Prevents TypeError when
a queued entry has null text that reaches .trim() during flush.

Add regression test: enqueue null-text entry alongside valid message,
verify flush completes without error and valid message is delivered.

Fixes openclaw#35777
Tardisyuan pushed a commit to Tardisyuan/openclaw that referenced this pull request Apr 30, 2026
)

Sanitize message text at the debounce enqueue boundary and add an
independent guard in combineDebounceEntries(). Prevents TypeError when
a queued entry has null text that reaches .trim() during flush.

Add regression test: enqueue null-text entry alongside valid message,
verify flush completes without error and valid message is delivered.

Fixes openclaw#35777
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
)

Sanitize message text at the debounce enqueue boundary and add an
independent guard in combineDebounceEntries(). Prevents TypeError when
a queued entry has null text that reaches .trim() during flush.

Add regression test: enqueue null-text entry alongside valid message,
verify flush completes without error and valid message is delivered.

Fixes openclaw#35777
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
)

Sanitize message text at the debounce enqueue boundary and add an
independent guard in combineDebounceEntries(). Prevents TypeError when
a queued entry has null text that reaches .trim() during flush.

Add regression test: enqueue null-text entry alongside valid message,
verify flush completes without error and valid message is delivered.

Fixes openclaw#35777
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: bluebubbles Channel integration: bluebubbles maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BlueBubbles: debounce flush crashes on null text (.trim() on null)

1 participant