fix(gateway): SSE buffer cap, yuanbao reconnect singleton, WhatsApp Cloud allowlist env vars (3-PR salvage) - #58504
Merged
Merged
Conversation
_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
enabled auto-merge (rebase)
July 5, 2026 07:35
teknium1
force-pushed
the
salvage/gateway-delivery-hardening
branch
from
July 5, 2026 07:36
59173ac to
8a76b8c
Compare
19 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_USERSenv 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
gateway/run.py: 16 MiB cap on the proxy SSE residual buffer; overflow routes to the existing "Proxy connection error" pathgateway/platforms/yuanbao.py:_do_reconnect()callsset_active(adapter)— mirrorsconnect(); fixesget_active()returning None forever after a reconnect (Yuanbao cron delivery silently fails after WS reconnect (three causes) #58363, cause 3)gateway/platforms/whatsapp_cloud.py:_allow_fromalso readsWHATSAPP_CLOUD_ALLOWED_USERS; dm_policy defaults toallowlistwhen an allowlist exists;_open_dm_opted_in()honorsWHATSAPP_CLOUD_ALLOW_ALL_USERS. Explicit config still wins; unconfigured default unchangedValidation
Targeted suites: proxy_mode, yuanbao reconnect, whatsapp_cloud (+ new allowed-users tests) — all pass.
Closes #58472. Closes #58378. Closes #58448.
Infographic