fix(qqbot): accept 'dm' session key in approval authorization (#34432) - #34438
Closed
liuhao1024 wants to merge 1 commit into
Closed
fix(qqbot): accept 'dm' session key in approval authorization (#34432)#34438liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
The approval click authorization in _is_authorized_interaction_for_session only matched chat_type == 'c2c', but build_session_key() produces session keys with chat_type='dm' for C2C (private) messages. This caused every approval button click on C2C sessions to be rejected as unauthorized. Fix by accepting both 'c2c' and 'dm' in the private-message branch. Fixes NousResearch#34432
Collaborator
Contributor
Author
|
Closing as duplicate per triage. |
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
When Hermes QQ Bot receives a C2C (private) message and the dangerous-command approval flow triggers, clicking the approval button is always rejected with:
Root cause:
build_session_key()producesagent:main:qqbot:dm:<openid>for C2C messages (chat_type="dm"), but_is_authorized_interaction_for_session()only checkschat_type == "c2c". The"dm"identifier never matches, so every C2C approval click is rejected.Fix: Accept both
"c2c"and"dm"in the private-message authorization branch, since both identifiers refer to the same C2C conversation type — just from different code paths.Fixes #34432
Code Intelligence
gateway/platforms/qqbot/adapter.py_is_authorized_interaction_for_session()and_parse_gateway_session_key()(line 1082-1085)"dm"to accepted set without removing"c2c")build_session_key()ingateway/session.py(line 631) produces"dm"for all DM chat types;parse_interaction_event()inkeyboards.py(line 459) maps QQ APIchat_type=2→scene="c2c"Changes
gateway/platforms/qqbot/adapter.py: accept"dm"alongside"c2c"in_is_authorized_interaction_for_sessiontests/gateway/test_qqbot.py: regression testtest_approval_click_accepts_dm_session_keyverifying approval clicks work with"dm"format session keysTesting