fix(weixin): scope split_multiline_messages under multiplex profiles

Every other WEIXIN_* tunable in this __init__ block (dm_policy,
group_policy, rate_limit_circuit_*, send_chunk_*) already reads
extra-first with a scoped-secret fallback via _extra_or_secret(). This
one field was missed and still fell back to a bare os.getenv(), so a
secondary profile without its own split_multiline_messages setting
silently inherited the default profile's process-env value instead of
the coded default.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
(cherry picked from commit 44e3c0d5cf276a4ef78e676f2631fe89b11b5893)
This commit is contained in:
EloquentBrush0x
2026-09-13 20:26:39 +03:00
committed by Teknium
parent 3ef1c4200b
commit 33c872e52e
2 changed files with 36 additions and 1 deletions
+1 -1
View File
@@ -710,7 +710,7 @@ class WeixinAdapter(OwnAccessPolicyMixin, BasePlatformAdapter):
allow_from, group_allow_from = extra.get("allow_from"), extra.get("group_allow_from")
self._allow_from = self._coerce_list(_wx_secret("WEIXIN_ALLOWED_USERS", "") if allow_from is None else allow_from)
self._group_allow_from = self._coerce_list(_wx_secret("WEIXIN_GROUP_ALLOWED_USERS", "") if group_allow_from is None else group_allow_from)
self._split_multiline_messages = _coerce_bool(extra.get("split_multiline_messages") or os.getenv("WEIXIN_SPLIT_MULTILINE_MESSAGES"), default=False)
self._split_multiline_messages = _coerce_bool(_extra_or_secret(extra, "split_multiline_messages", ""), default=False)
# Text debounce batching (Telegram pattern): iLink delivers messages individually, so rapid bursts would each
# trigger a separate agent run. 3s / 5s (after a ~2048-char split chunk) suit iLink's cadence.
self._text_batch_delay_seconds = self._coerce_float_extra("text_batch_delay_seconds", 3.0)
+35
View File
@@ -147,3 +147,38 @@ class TestWeixinAdapterAuthzScope:
assert adapter._dm_policy == "pairing"
assert adapter._allow_from == []
assert adapter._is_dm_allowed("default-user") is False
class TestWeixinAdapterSplitMultilineScope:
"""``split_multiline_messages`` must follow the same scoped-secret rules
as every other WEIXIN_* tunable in this block (missed by the
scoped-reader retrofit): a secondary profile's own scope is
authoritative, and the default profile's process-env value must not
leak into it."""
def test_scoped_construction_reads_split_multiline_from_scope_not_environ(
self, multiplex_on, monkeypatch
):
monkeypatch.setenv("WEIXIN_SPLIT_MULTILINE_MESSAGES", "false")
token = secret_scope.set_secret_scope(
{"WEIXIN_SPLIT_MULTILINE_MESSAGES": "true"}
)
try:
adapter = WeixinAdapter(PlatformConfig(enabled=True))
finally:
secret_scope.reset_secret_scope(token)
assert adapter._split_multiline_messages is True
def test_scoped_miss_does_not_borrow_default_profiles_split_multiline(
self, multiplex_on, monkeypatch
):
"""A secondary profile with no split_multiline_messages of its own
must fall back to the coded default, not inherit the default
profile's env-only value."""
monkeypatch.setenv("WEIXIN_SPLIT_MULTILINE_MESSAGES", "true")
token = secret_scope.set_secret_scope({"SOMETHING_ELSE": "x"})
try:
adapter = WeixinAdapter(PlatformConfig(enabled=True))
finally:
secret_scope.reset_secret_scope(token)
assert adapter._split_multiline_messages is False