fix(gateway): revert Weixin get_secret() calls that crash in multiplex mode - #68854
Closed
WenhuaXia wants to merge 1 commit into
Closed
fix(gateway): revert Weixin get_secret() calls that crash in multiplex mode#68854WenhuaXia wants to merge 1 commit into
WenhuaXia wants to merge 1 commit into
Conversation
WenhuaXia
force-pushed
the
fix/weixin-get-secret-multiplex
branch
2 times, most recently
from
July 29, 2026 17:46
814b449 to
7350d54
Compare
Contributor
|
Thanks for isolating the primary-adapter startup failure; the current main path does reproduce it. Problems
Suggested changes
This is an automated hermes-sweeper review. |
…x mode Commit 6160a80 replaced os.getenv() with get_secret() for Weixin credential resolution, but WeixinAdapter.__init__() and send_weixin_direct() are called outside any secret_scope context. When multiplex_profiles is enabled, get_secret() raises UnscopedSecretError, preventing the platform adapter from initializing and blocking the entire gateway startup sequence. Revert to os.getenv() which is the correct fallback for credential resolution outside a scoped context. The config.yaml → env bridge in gateway/config.py already loads WEIXIN_* values into the PlatformConfig object (token/account_id), so os.getenv() serves only as the final fallback for extra config keys.
WenhuaXia
force-pushed
the
fix/weixin-get-secret-multiplex
branch
from
August 2, 2026 05:13
7350d54 to
8bf2fb2
Compare
teknium1
added a commit
that referenced
this pull request
Aug 2, 2026
The adapter's __init__ and send_weixin_direct read WEIXIN_ACCOUNT_ID/ TOKEN/BASE_URL/CDN_BASE_URL via bare get_secret, which raises UnscopedSecretError when the DEFAULT profile's adapter constructs or sends unscoped under multiplexing (corrects the direction of #66073 / #68854, which tried to solve this by borrowing os.environ on every read — a cross-profile leak). Add a module-level _wx_secret helper following the established Slack SLACK_APP_TOKEN pattern (#59739) and WhatsApp's _get_wsecret: a SCOPED miss returns the default (the scope is authoritative — no environ borrow), while an UNSCOPED read under multiplex falls back to os.environ, which is the default profile's own value. Regression tests cover both directions: scoped construction reads the scope's value and a scoped miss yields empty (no borrow); unscoped construction falls back to os.environ instead of raising.
Contributor
|
Closing in favor of the merged correction (#76663), same grounds as the sibling #66073: the unscoped-construction crash was real, but reverting to raw environ reads re-opens the cross-profile token leak for secondary profiles. Main now applies the Slack-pattern wx_secret helper to all WEIXIN* reads — including send_weixin_direct (:2316-2319), which your PR correctly identified as also affected; that finding carried into the fix. Thanks @WenhuaXia. |
randlee
pushed a commit
to randlee/hermes-agent
that referenced
this pull request
Aug 11, 2026
The adapter's __init__ and send_weixin_direct read WEIXIN_ACCOUNT_ID/ TOKEN/BASE_URL/CDN_BASE_URL via bare get_secret, which raises UnscopedSecretError when the DEFAULT profile's adapter constructs or sends unscoped under multiplexing (corrects the direction of NousResearch#66073 / NousResearch#68854, which tried to solve this by borrowing os.environ on every read — a cross-profile leak). Add a module-level _wx_secret helper following the established Slack SLACK_APP_TOKEN pattern (NousResearch#59739) and WhatsApp's _get_wsecret: a SCOPED miss returns the default (the scope is authoritative — no environ borrow), while an UNSCOPED read under multiplex falls back to os.environ, which is the default profile's own value. Regression tests cover both directions: scoped construction reads the scope's value and a scoped miss yields empty (no borrow); unscoped construction falls back to os.environ instead of raising.
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.
Problem
Commit 6160a80 replaced
os.getenv()withget_secret()for Weixin credential resolution. However,WeixinAdapter.__init__()andsend_weixin_direct()are called outside anysecret_scopecontext. Whenmultiplex_profiles: trueis enabled,get_secret()raisesUnscopedSecretError, preventing the platform adapter from initializing and blocking the entire gateway startup sequence.Reproduction:
multiplex_profiles: trueinconfig.yaml.envUnscopedSecretError: get_secret('WEIXIN_CDN_BASE_URL') called with no profile secret scope activeFix
Revert to
os.getenv()which is the correct fallback for credential resolution outside a scoped context. The config.yaml → env bridge ingateway/config.pyalready loads WEIXIN_* values into the PlatformConfig object (token/account_id), soos.getenv()serves only as the final fallback for extra config keys.Files Changed
gateway/platforms/weixin.py: Reverted 4get_secret()calls toos.getenv()in bothWeixinAdapter.__init__()andsend_weixin_direct()Verification
multiplex_profiles: true