fix(qqbot): authorize approval buttons for named-profile session keys - #98294
Open
LovePlayCode wants to merge 1 commit into
Open
fix(qqbot): authorize approval buttons for named-profile session keys#98294LovePlayCode wants to merge 1 commit into
LovePlayCode wants to merge 1 commit into
Conversation
Contributor
Overall: Minimal fix for named-profile approval authorization. What it does
Non-blocking notes
No functional issues found. Non-blocking — please use your judgment. |
`_parse_gateway_session_key()` required the literal `main` in the
namespace slot of `agent:<ns>:<platform>:<chat_type>:<chat_id>`, but
`_session_key_namespace()` (gateway/session.py) puts the multiplex
profile name there for named profiles. Every approval button click in a
named-profile QQ session therefore failed authorization ("Rejected
unauthorized approval click") and the pending approval timed out
fail-closed.
The namespace slot takes no part in any authorization decision, so the
parser now accepts any non-empty namespace; the platform and operator
checks are unchanged and pinned by new negative tests.
Fixes NousResearch#98292
LovePlayCode
force-pushed
the
fix/qqbot-profile-approval-authz
branch
from
August 31, 2026 07:57
175b96f to
8e0f02e
Compare
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.
What does this PR do?
In a named profile (gateway multiplexing), every QQBot approval-button click was rejected as unauthorized and the pending approval timed out fail-closed (300s → command BLOCKED).
Root cause:
_parse_gateway_session_key()(introduced with the owner-authorization check in #30737) required the literalmainin the namespace slot ofagent:<ns>:<platform>:<chat_type>:<chat_id>, but_session_key_namespace()(gateway/session.py) puts the multiplex profile name there for named profiles — a design that is explicitly documented as position-compatible for downstream parsers. Soagent:coder:qqbot:dm:<openid>failed to parse,_is_authorized_interaction_for_session()returnedFalse, and the click was dropped withRejected unauthorized approval click.This is not the dm/c2c chat_type family (#32528 & the ~25 PRs addressing it, including the broadest #40705) — those fix a different slot of the same key. This PR fixes the namespace slot; the two changes are orthogonal and can merge independently. Telegram / Slack / Teams already have profile-aware authorization fixes in flight (#65589 / #72657 / #93516); this is the QQBot counterpart.
The fix: drop the
parts[1] != "main"assertion, keeping a non-empty check so malformed keys (agent::qqbot:...) are still rejected. The namespace slot takes no part in any authorization decision — theplatform == "qqbot",operator == chat_id(c2c) andoperator == session_user(group/guild) checks are what authorize, and they are unchanged and pinned by new negative tests.Related Issue
Fixes #98292
Type of Change
Changes Made
gateway/platforms/qqbot/adapter.py—_parse_gateway_session_key(): accept any non-empty namespace (multiplex profile) instead of requiring the literalmain; docstring updated to document the namespace slottests/gateway/test_qqbot.py— newTestProfileNamespaceApprovalAuthz(6 tests): named-profile keys parse; defaultagent:main:...keys unchanged (no regression); malformed keys still rejected; end-to-end c2c/group approval clicks on named-profile keys resolve viaresolve_gateway_approval; a wrong-operator click on a named-profile key is still rejected (the relaxation does not weaken the operator check)How to Test
uv run --extra dev pytest tests/gateway/test_qqbot.py -q→ 69 passed (63 before + 6 new)git stash push gateway/platforms/qqbot/adapter.py):uv run --extra dev pytest tests/gateway/test_qqbot.py::TestProfileNamespaceApprovalAuthz -q→ 3 failed (the positive named-profile cases fail, reproducing the production log lineRejected unauthorized approval click for session agent:coder:qqbot:group:g-1:owner); restored → 6 passeduv run --extra dev pytest tests/gateway/test_qqbot_credential_isolation.py tests/gateway/test_qqbot_scope_paths.py -q→ 19 passedmain:Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests pass (targeted suites above; full-suite run pending CI)Documentation & Housekeeping
Screenshots / Logs
Mutation-check run with the fix reverted reproduces the reported failure mode: