Skip to content

[Bug] QQ Official Webhook fails in unified_webhook_mode: DashboardRequest has no 'get_data' #9287

Description

@AKer4632

Description

When using QQ Official Webhook adapter with unified_webhook_mode: true, all incoming webhook callbacks crash with AttributeError: 'DashboardRequest' object has no attribute 'get_data'.

The unified webhook entry (dashboard/services/platform_service.py) passes a DashboardRequest instance to QQOfficialWebhookPlatformAdapter.webhook_callback(), which then delegates to QQOfficialWebhook.handle_callback(). However, handle_callback() unconditionally calls await request.get_data(), which is a Flask Request API. DashboardRequest (and Starlette Request) does not have this method.

Traceback

File "/AstrBot/astrbot/dashboard/services/platform_service.py", line 50, in handle_webhook_callback
    return await platform_adapter.webhook_callback(request_obj)
File "/AstrBot/astrbot/core/platform/sources/qqofficial_webhook/qo_webhook_adapter.py", line 215, in webhook_callback
    return await self.webhook_helper.handle_callback(request)
File "/AstrBot/astrbot/core/platform/sources/qqofficial_webhook/qo_webhook_server.py", line 178, in handle_callback
    body = await request.get_data()
AttributeError: 'DashboardRequest' object has no attribute 'get_data'

Affected File

astrbot/core/platform/sources/qqofficial_webhook/qo_webhook_server.py

Root Cause

DashboardRequest wraps a Starlette Request. It exposes:

  • request.headers
  • request.json (property)
  • request.body()but only via the internal _request (Starlette Request)

There is no .get_data() (Flask) nor .body() (Starlette/FastAPI) directly on DashboardRequest.

Suggested Fix

In qo_webhook_server.py, line 178, change:

body = await request.get_data()

To:

if hasattr(request, "body"):
    body = await request.body()
elif hasattr(request, "get_data"):
    body = await request.get_data()
else:
    body = await request._request.body()

This covers all three cases:

  1. Starlette/FastAPI Requestawait request.body()
  2. Flask Requestawait request.get_data()
  3. DashboardRequest → falls back to await request._request.body()

Environment

  • AstrBot version: latest (as of 2026-07-15)
  • Adapter: qq_official_webhook
  • unified_webhook_mode: true in platform config

Checklist

  • I have searched existing issues and confirmed this is not a duplicate.
  • I have provided the full traceback.
  • I have suggested a minimal fix.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:platformThe bug / feature is about IM platform adapter, such as QQ, Lark, Telegram, WebChat and so on.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions