Skip to content

fix(gateway): SSE buffer cap, yuanbao reconnect singleton, WhatsApp Cloud allowlist env vars (3-PR salvage) - #58504

Merged
teknium1 merged 5 commits into
mainfrom
salvage/gateway-delivery-hardening
Jul 5, 2026
Merged

fix(gateway): SSE buffer cap, yuanbao reconnect singleton, WhatsApp Cloud allowlist env vars (3-PR salvage)#58504
teknium1 merged 5 commits into
mainfrom
salvage/gateway-delivery-hardening

Conversation

@teknium1

@teknium1 teknium1 commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Three gateway delivery fixes: the proxy-mode SSE parser can no longer grow an unbounded line buffer (16 MiB cap), the Yuanbao adapter singleton is restored after a WS reconnect so deliveries stop permanently failing, and WhatsApp Cloud finally honors the documented WHATSAPP_CLOUD_ALLOWED_USERS / WHATSAPP_CLOUD_ALLOW_ALL_USERS env vars instead of silently dropping every inbound message.

Salvages #58472 (@ooiuuii), #58378 (@liuhao1024), #58448 (@sahil-shubham) onto current main, authorship preserved. #58379 (@ngleoi) contains the identical yuanbao singleton line and is credited below; its retry-delivery layer is deferred (leftover diagnostics, duplicated delivery branch — see close comment).

Changes

Validation

Before After
boundary-less SSE upstream unbounded memory growth capped, error surfaced
yuanbao WS reconnect deliveries fail permanently singleton restored
wizard-configured WhatsApp Cloud allowlist every message silently dropped allowlist enforced

Targeted suites: proxy_mode, yuanbao reconnect, whatsapp_cloud (+ new allowed-users tests) — all pass.

Closes #58472. Closes #58378. Closes #58448.

Infographic

gateway-delivery-hardening

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery platform/whatsapp WhatsApp Business adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages P2 Medium — degraded but workaround exists labels Jul 4, 2026
ooiuuii and others added 4 commits July 5, 2026 00:35
_do_reconnect() succeeded but never called
YuanbaoAdapter.set_active(adapter), leaving get_active()
permanently returning None after any WS disconnect/reconnect
cycle. This caused cron delivery to silently fail because
_send_yuanbao() checks get_active_adapter() and gives up
immediately when it returns None.

Fix: call set_active(adapter) after successful reconnect,
matching the pattern in connect().

Fixes #58363
…ALLOW_ALL_USERS

The Cloud setup wizard and docs tell operators to set
WHATSAPP_CLOUD_ALLOWED_USERS (and WHATSAPP_CLOUD_ALLOW_ALL_USERS), but the
adapter DM intake gate only read WHATSAPP_CLOUD_ALLOW_FROM + WHATSAPP_CLOUD_DM_POLICY
(default open, opted-in only via GATEWAY_/WHATSAPP_ALLOW_ALL_USERS). So an
allowlist set via the documented var silently dropped every inbound
(_should_process_message -> None -> HTTP 200, no dispatch, no log line).

- _allow_from also reads WHATSAPP_CLOUD_ALLOWED_USERS
- dm_policy defaults to allowlist when an allowlist is present (else open)
- _open_dm_opted_in() also honors WHATSAPP_CLOUD_ALLOW_ALL_USERS

Explicit DM_POLICY / ALLOW_FROM still win -> backward compatible.
…env vars

Follow-up for salvaged #58448 which shipped without tests.
@teknium1
teknium1 enabled auto-merge (rebase) July 5, 2026 07:35
@teknium1
teknium1 force-pushed the salvage/gateway-delivery-hardening branch from 59173ac to 8a76b8c Compare July 5, 2026 07:36
@teknium1
teknium1 merged commit d810ff2 into main Jul 5, 2026
29 checks passed
@teknium1
teknium1 deleted the salvage/gateway-delivery-hardening branch July 5, 2026 07:41
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 P2 Medium — degraded but workaround exists platform/whatsapp WhatsApp Business adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants