Skip to content

fix(bluebubbles): bound REST JSON responses - #55275

Open
ooiuuii wants to merge 1 commit into
NousResearch:mainfrom
ooiuuii:fix/bluebubbles-response-cap
Open

ooiuuii wants to merge 1 commit into
NousResearch:mainfrom
ooiuuii:fix/bluebubbles-response-cap

Conversation

@ooiuuii

@ooiuuii ooiuuii commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #55274

Summary

  • Switch BlueBubbles REST JSON helpers from buffered get() / post() calls to client.stream(...).
  • Add a 16 MiB cap while reading JSON response bytes and close the stream immediately when the cap is exceeded.
  • Apply the same bounded JSON reader to the attachment-upload response body.
  • Update BlueBubbles tests with stream-aware fakes and coverage for normal JSON reads, oversized stream closure, and attachment-upload response parsing.

Scope

This intentionally does not change inbound attachment downloads. That is a separate media/cache-helper boundary and overlaps historical work such as #35297 / #42931.

Validation

  • C:\Users\Administrator\Documents\Codex\2026-06-29\hermes-main-latest-scan\.venv\Scripts\python.exe -m pytest tests\gateway\test_bluebubbles.py -q --basetemp .pytest-tmp-bluebubbles-response-cap-venv → 59 passed
  • C:\Users\Administrator\Documents\Codex\2026-06-29\hermes-main-latest-scan\.venv\Scripts\python.exe -m ruff check gateway\platforms\bluebubbles.py tests\gateway\test_bluebubbles.py → All checks passed
  • git diff --check

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: LGTM

Good security fix. Replaces buffered REST JSON helpers with streaming reads and adds a 16 MiB body cap for BlueBubbles API responses. Prevents memory exhaustion from oversized upstream responses.

  • Clean streaming pattern with size enforcement
  • Consistent with similar bounding PRs in the batch
  • Well-scoped: 2 files, 180 additions

Reviewed 2 files, 180 additions. Approved.

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery labels Jun 30, 2026
@alt-glitch

Copy link
Copy Markdown
Contributor

This was generated by AI during triage.

Fix PR for #55274 (issue<->fix pair, same author) — linking as related, not duplicate. Same bounded-REST-JSON hardening class as your Mattermost (#54754) and Discord standalone-send (#55209) PRs.

@teknium1

Copy link
Copy Markdown
Collaborator

Thanks for the focused BlueBubbles hardening. The premise remains present on current main: _api_get and _api_post buffer REST responses before JSON parsing at gateway/platforms/bluebubbles.py:225 and gateway/platforms/bluebubbles.py:231; attachment upload has the same pattern at gateway/platforms/bluebubbles.py:595.

The PR's streamed, byte-capped JSON reader directly addresses those JSON-consuming paths and includes coverage for normal streaming, the oversize path, and attachment-upload parsing. No blocking correctness issue was identified from the diff and current-main inspection. Current main has moved only in adjacent BlueBubbles webhook and GUID-resolution work, so this appears suitable for mechanical cherry-pick/salvage rather than reimplementation.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BlueBubbles REST helpers buffer JSON responses without a cap

4 participants