fix(qqbot): authorize dm chat_type in interaction approval - #32752
Conversation
QQBot DM session keys are constructed with chat_type="dm" (see SessionDB session_key), but _is_authorized_interaction_for_session matched only the literal "c2c". Every approval / update button click in QQ private chat was therefore rejected with "Rejected unauthorized approval click", and any tool requiring user approval would block forever. Accept both literals and add regression tests covering c2c, dm, group/guild, malformed keys, and platform mismatches. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Cross-reference: this PR also resolves #34432 (QQ Bot approval button clicks rejected for C2C/private messages). Verified against current One clarification on #34432's stated root cause: that issue claims This PR's |
|
Thanks for the focused QQBot regression fix. Current The proposed |
Problem
Approval / update button clicks from QQ private chats are unconditionally rejected with:
…even though the operator's
openidmatches the session owner. As a result, any tool requiring user approval (sensitive commands, MCP confirmations, etc.) blocks the agent indefinitely on the QQBot platform.Root cause
QQBot DM session keys are constructed as
agent:main:qqbot:dm:<openid>, so_parse_gateway_session_keyreturnschat_type == "dm". But_is_authorized_interaction_for_sessiononly accepts the literalc2c:DMs fall through to the final
return Falseand the click is rejected.Fix
Accept both
c2c(legacy literal) anddm(what the SessionDB actually emits for QQ private chats).Tests
Adds
TestIsAuthorizedInteractionForSessionwith 11 cases:All 170 tests in
tests/gateway/test_qqbot.pypass after the fix; the newtest_dm_match_grantsreliably fails againstmain(verified by reverting the one-line change locally), so it is real regression coverage rather than tautology.Reproduction
Reproduced live in a private QQBot deployment: prior to the fix, every approval button click in a QQ DM produced the unauthorized warning and the tool call hung. After the fix, the same click logged:
…and the agent continued normally.
Made with Cursor