fix(qqbot): accept dm chat_type in approval authorization - #76114
Open
zhangyu921 wants to merge 1 commit into
Open
zhangyu921 wants to merge 1 commit into
zhangyu921 wants to merge 1 commit into
Conversation
QQ Bot DM (C2C) sessions build their gateway session key with chat_type="dm" (build_session_key in gateway/session.py), but _is_authorized_interaction_for_session in the qqbot adapter only accepted "c2c"/"group"/"guild". DM approval button clicks therefore fell through to return False and were rejected as unauthorized, making command approval via inline keyboard unusable in QQ private chats. Treat "dm" like "c2c" (both are 1:1 user chats) while leaving the group/guild checks unchanged.
teknium1
reviewed
Aug 1, 2026
teknium1
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the focused QQBot authorization fix. Current main still has the reported mismatch: QQ C2C intake creates chat_type="dm" sources at gateway/platforms/qqbot/adapter.py:1293-1299, and build_session_key() serializes those as ...:dm:<chat_id> at gateway/session.py:1074-1086. The existing authorization branch accepts only c2c at gateway/platforms/qqbot/adapter.py:1105, then rejects other types at line 1115.
Problems
- This PR has no regression test. Existing dispatch coverage tests a C2C owner path at
tests/gateway/test_qqbot.py:853and an unauthorized group path at line 884, but not the DM-shaped key this change enables.
Suggested changes
- Add the focused DM approval-dispatch test already represented by the earlier canonical PR #31593: a matching operator for
agent:main:qqbot:dm:u-42should resolve the approval.
Automated hermes-sweeper review.
| chat_type = parsed.get("chat_type", "") | ||
| chat_id = parsed.get("chat_id", "") | ||
| if chat_type == "c2c": | ||
| if chat_type in {"c2c", "dm"}: |
Collaborator
There was a problem hiding this comment.
Please add a dispatch-level regression test for a matching C2C operator clicking approve:agent:main:qqbot:dm:<openid>:allow-once; the current tests cover the analogous c2c key but not this newly accepted dm form.
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
QQ Bot DM (C2C) sessions build their gateway session key with
chat_type="dm"(seebuild_session_keyingateway/session.py, which useschat_type="dm"for DMs). But_is_authorized_interaction_for_sessionin the qqbot adapter only acceptedc2c/group/guild.Result: every approval-button click in a QQ private chat falls through to
return Falseand is logged as:Command approval via inline keyboard is completely unusable in QQ DMs. Group/guild approvals are unaffected.
Fix
Treat
dmlikec2c— both are 1:1 user chats where the operator's openid must equal the chat id. Group/guild logic unchanged.Verification
dm+ owner → authorized (was rejected before)dm+ attacker → still rejected (no permission loosened)c2c+ owner → authorized (regression pass)group+ other user → still rejected (regression pass)