Skip to content

fix(qqbot): approval button auth rejects DM sessions - #33962

Closed
renjk wants to merge 2 commits into
NousResearch:mainfrom
renjk:fix/qqbot-approval-dm-auth
Closed

fix(qqbot): approval button auth rejects DM sessions#33962
renjk wants to merge 2 commits into
NousResearch:mainfrom
renjk:fix/qqbot-approval-dm-auth

Conversation

@renjk

@renjk renjk commented May 28, 2026

Copy link
Copy Markdown

Bug

QQ bot approval buttons (inline keyboard) are rejected as unauthorized in c2c (direct message) sessions.

Root Cause

The gateway generates session keys with dm as the chat_type for QQ direct messages:

agent:main:qqbot:dm:737E35A85CAE35BBA83817D3FEFD95A4

But _is_authorized_interaction_for_session() only checks for c2c:

if chat_type == c2c:  # never matches dm
    return bool(chat_id) and operator == chat_id
return False  # ← always rejected

Fix

Accept both c2c and dm as valid chat_type values for direct message authorization:

if chat_type in (c2c, dm):

Impact

Without this fix, all QQ DM approval button clicks are silently rejected, causing approval timeouts. Users have to fall back to text-based /approve commands.

Testing

Verified on QQ bot (c2c session) — approval buttons now work correctly after the fix.

renjk added 2 commits May 28, 2026 23:53
Added 20 new file extensions to the media_pattern regex in
BasePlatformAdapter.extract_media():

Code: py, js, ts, sh, rb, go, rs, java, c, cpp, h
Config/Data: yaml, yml, toml, json, xml, sql
Markup: md, html, htm, css

Previously only media/document formats were supported (png, jpg,
pdf, zip, docx, etc.). Users can now send code and config files
via MEDIA: tag across all messaging platforms.
…_type

The gateway generates session keys with 'dm' for QQ direct messages
(e.g. agent:main:qqbot:dm:OPENID), but _is_authorized_interaction_for_session
only checked for 'c2c'. This caused all QQ c2c approval button clicks to be
rejected as unauthorized.

Fix: accept both 'c2c' and 'dm' as valid chat_type values for direct
message authorization.
@liuhao1024

Copy link
Copy Markdown
Contributor

I found one issue worth addressing before merge.

Bundled unrelated change: MEDIA regex extension in gateway/platforms/base.py

This PR modifies extract_media() in gateway/platforms/base.py to add code/text file extensions (.py, .js, .ts, .sh, .yaml, etc.) to the MEDIA regex. However, you already submitted this exact change as a standalone PR — #33960 (feat: add common code/text file extensions to MEDIA: tag support, same 1-line diff in base.py).

The qqbot DM authorization fix (chat_type in ("c2c", "dm")) in gateway/platforms/qqbot/adapter.py is a clean, focused fix. Mixing in the unrelated MEDIA regex change makes this PR harder to review and risks being rejected for scope creep.

Suggested fix: Remove the gateway/platforms/base.py hunk from this PR so it only contains the qqbot adapter change. Let #33960 handle the MEDIA regex extension separately.

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery platform/qqbot QQ Bot adapter P2 Medium — degraded but workaround exists duplicate This issue or pull request already exists labels May 28, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #31593 (and #32752). Same one-line fix: _is_authorized_interaction_for_session() accepts dm alongside c2c chat_type for QQBot DM approval clicks. All fix #32528.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists platform/qqbot QQ Bot adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants