Skip to content

fix(qqbot): accept dm chat_type in approval authorization - #48600

Open
warm-stone wants to merge 1 commit into
NousResearch:mainfrom
warm-stone:fix/qqbot-approval-chat-type
Open

fix(qqbot): accept dm chat_type in approval authorization#48600
warm-stone wants to merge 1 commit into
NousResearch:mainfrom
warm-stone:fix/qqbot-approval-chat-type

Conversation

@warm-stone

Copy link
Copy Markdown

The gateway normalizes every platform private (C2C) chat to chat_type "dm" in session keys (e.g. agent:main:qqbot:dm:), via build_source(chat_type="dm") in _handle_c2c_message and the shared base adapter. However _is_authorized_interaction_for_session only matched the QQ-specific term "c2c", so every private-chat approval/update button click fell through to return False and was rejected as unauthorized.

Symptom: clicking Allow once / Allow always / Deny in a QQ private chat logged "Rejected unauthorized approval click" and never unblocked the agent, so the gated terminal command timed out as BLOCKED. Telegram DMs were unaffected (their authorizer normalizes chat_type to "dm").

Fix: treat dm/private/direct as aliases of c2c in the private-chat authorization branch, matching the gateway-normalized session key. Added unit tests covering dm/c2c acceptance, wrong-operator and group-scene rejection, and malformed session keys.

What does this PR do?

Related Issue

Fixes #

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

How to Test

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform:

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

For New Skills

  • This skill is broadly useful to most users (if bundled) — see Contributing Guide
  • SKILL.md follows the standard format (frontmatter, trigger conditions, steps, pitfalls)
  • No external dependencies that aren't already available (prefer stdlib, curl, existing Hermes tools)
  • I've tested the skill end-to-end: hermes --toolsets skills -q "Use the X skill to do Y"

Screenshots / Logs

The gateway normalizes every platform private (C2C) chat to
chat_type "dm" in session keys (e.g. agent:main:qqbot:dm:<openid>),
via build_source(chat_type="dm") in _handle_c2c_message and the
shared base adapter. However _is_authorized_interaction_for_session
only matched the QQ-specific term "c2c", so every private-chat
approval/update button click fell through to return False and was
rejected as unauthorized.

Symptom: clicking Allow once / Allow always / Deny in a QQ private
chat logged "Rejected unauthorized approval click" and never
unblocked the agent, so the gated terminal command timed out as
BLOCKED. Telegram DMs were unaffected (their authorizer normalizes
chat_type to "dm").

Fix: treat dm/private/direct as aliases of c2c in the private-chat
authorization branch, matching the gateway-normalized session key.
Added unit tests covering dm/c2c acceptance, wrong-operator and
group-scene rejection, and malformed session keys.
@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 Jun 18, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #31593 — same one-line fix accepting dm/private/direct as aliases of c2c in _is_authorized_interaction_for_session() so QQ private-chat approval clicks aren't rejected. Part of the open cluster #31593/#32752/#36774/#40926. #31593 is the earliest still-open PR for this fix.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused regression fix. Current main still has the mismatch: QQ C2C intake creates chat_type="dm" at gateway/platforms/qqbot/adapter.py:1291-1297, and build_session_key() serializes that source as ...:qqbot:dm:<chat_id> at gateway/session.py:907-915. The authorization branch at gateway/platforms/qqbot/adapter.py:1103-1104 accepts only c2c, so the dispatcher rejects the valid click before resolving approval at gateway/platforms/qqbot/adapter.py:1148-1159.

The proposed condition preserves the existing exact owner comparison, and the regression tests cover the previously rejected DM-shaped session key. This is an automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 14, 2026
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 sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants