Skip to content

Feishu: Command Approval buttons return "出错了,请稍后再试 code: 220340" when clicked #13924

@matingxiu

Description

@matingxiu

Bug Description

When Hermes Gateway is running on the Feishu (Lark) platform and a dangerous command triggers the "Command Approval Required" interactive card, clicking any of the approval buttons (Allow Once, Session, Always, Deny) returns the error:

"出错了,请稍后再试 code: 220340"

The approval action is never processed — the agent remains blocked waiting for a response.

Steps to Reproduce

  1. Connect Hermes Gateway to Feishu platform
  2. Trigger a command that requires approval (e.g., curl -fsSL https://deb.nodesource.com/setup_20.x | bash -)
  3. The bot sends an interactive card with buttons: ✅ Allow Once, ✅ Session, ✅ Always, ❌ Deny
  4. Click any button
  5. Error returned: "出错了,请稍后再试 code: 220340"

Expected Behavior

Clicking an approval button should resolve the pending approval and unblock the agent, executing or denying the command accordingly.

Actual Behavior

Feishu returns error code 220340 when the bot tries to call im.message.update (or equivalent card update API) to replace the approval card with a resolution card (e.g., "Approved by user"). The approval resolution logic itself appears correct (_resolve_approval is called, resolve_gateway_approval succeeds), but the subsequent card update fails.

Root Cause Analysis

In gateway/platforms/feishu.py, the method _handle_approval_card_action:

  1. Successfully extracts approval_id and maps the button click to a choice
  2. Successfully schedules _resolve_approval() via asyncio.run_coroutine_threadsafe() — the approval is resolved
  3. Attempts to update the approval card by returning a P2CardActionTriggerResponse with a CallBackCard containing the resolution text

The error 220340 is a Feishu API error (not a Hermes error code) that occurs when the bot attempts to update the message/card. Possible causes:

  • Permission issue: The bot may not have im:message write permission for the specific chat
  • Message ID issue: The message_id stored in _approval_state may not be the correct open_chat_id format needed for im.message.update
  • Card update restriction: Feishu interactive cards may not support update operations on cards that were sent as new messages (vs. message replies)

Environment

  • Hermes Agent version: v0.10.0 (2026.4.16)
  • Platform: Feishu/Lark (gateway)
  • Python: 3.11

Workaround

Use /approve or /deny slash commands instead of clicking the interactive card buttons.

Tags

  • bug
  • platform:feishu
  • priority:medium

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/gatewayGateway runner, session dispatch, deliveryplatform/feishuFeishu / Lark adaptertype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions