fix(qqbot): authorize approval clicks for DM sessions (chat_type='dm') - #35774
Closed
luyao618 wants to merge 1 commit into
Closed
fix(qqbot): authorize approval clicks for DM sessions (chat_type='dm')#35774luyao618 wants to merge 1 commit into
luyao618 wants to merge 1 commit into
Conversation
Fixes NousResearch#35760 The QQ adapter creates direct-message sessions with chat_type="dm" (see _on_c2c_message_create / _on_friend_add: chat_type="dm"), but _is_authorized_interaction_for_session only accepted chat_type=="c2c". As a result, approval button clicks on QQ DMs were always rejected with 'Rejected unauthorized approval click', blocking every tool requiring user approval until the ~280s approval timeout fired. Accept both legacy 'c2c' and current 'dm' chat_type values. Adds regression tests covering DM accept, c2c accept, and DM mismatch reject.
Collaborator
This was referenced May 31, 2026
Contributor
Author
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
Fixes #35760 — QQ bot approval button clicks (e.g.
allow-once,allow-always) were always rejected withRejected unauthorized approval click for session ..., blocking every tool requiring user approval until the ~280s approval timeout fired.Root cause
gateway/platforms/qqbot/adapter.py::_is_authorized_interaction_for_sessiononly matchedchat_type == "c2c". But this adapter creates DM sessions withchat_type="dm":Session keys therefore look like
agent:main:qqbot:dm:<openid>, which parses tochat_type="dm"and never matches"c2c", so every DM approval click falls through toreturn False.Fix
One-line: accept both legacy
"c2c"and current"dm"chat_type values.Group/guild branches are unchanged.
Tests
Adds three regression tests in
tests/gateway/test_qqbot.py::TestIsAuthorizedInteractionForSession:test_dm_chat_type_authorizes_when_operator_matches_chat_id— the bug casetest_c2c_chat_type_still_authorizes— backward-compat guardtest_dm_chat_type_rejects_when_operator_mismatched— ensures we still reject impostorsFull file passes:
162 passed.Risk
Minimal. Pure widening of an existing auth predicate. Operator-equality check is unchanged, so security posture is identical to the c2c path.