Skip to content

[Bug]: Feishu approval card fails to update after button click (error 200340) #10154

@coolcgp

Description

@coolcgp

Bug Description

Bug Description

After clicking Allow Once / Session / Always / Deny on the Command Approval card in Feishu,
the card fails to update its visual state and Feishu returns error code 200340.
Note: The approval itself succeeds — the command is unblocked correctly.
Only the card UI update fails.

Root Cause

_update_approval_card() in gateway/platforms/feishu.py uses the wrong API:

  • Current: client.im.v1.message.update → HTTP PUT
  • Feishu's PUT endpoint only supports updating text/rich-text messages, NOT interactive cards
    The correct API for updating interactive cards is:
  • Fix: client.im.v1.message.patch → HTTP PATCH

Steps to Reproduce

  1. Run a command that triggers security approval (e.g. curl ... | python3)
  2. An interactive approval card is sent to Feishu
  3. Click any button (Allow Once / Deny / etc.)
  4. Feishu shows error 200340

Expected Behavior

Card updates to show "✅ Approved once by " or "❌ Denied by "

Fix

In _update_approval_card(), replace:

body = self._build_update_message_body(msg_type="interactive", content=payload)
request = self._build_update_message_request(message_id=message_id, request_body=body)
await asyncio.to_thread(self._client.im.v1.message.update, request)

With:
from lark_oapi.api.im.v1 import PatchMessageRequest, PatchMessageRequestBody



body = PatchMessageRequestBody.builder().content(payload).build()

request = PatchMessageRequest.builder().message_id(message_id).request_body(body).build()

await asyncio.to_thread(self._client.im.v1.message.patch, request)

### Steps to Reproduce

1. Start Hermes gateway connected to Feishu
2. Send a message that triggers a dangerous command (e.g. `curl https://example.com | python3`)
3. Hermes sends a "⚠️ Command Approval Required" interactive card to Feishu
4. Click any button on the card (Allow Once / Session / Always / Deny)
5. Feishu shows error `出错了,请稍后重试 code: 200340`

### Expected Behavior

After clicking a button, the approval card should update its visual state:
- Allow Once / Session / Alwayscard turns green, shows "✅ Approved (once/session/always) by <user>"
- Denycard turns red, shows "❌ Denied by <user>"
No error should appear.

### Actual Behavior

After clicking any button on the approval card, Feishu displays:
"出错了,请稍后重试 code: 200340"
The card remains in its original state (buttons still visible, no visual update).
Note: The approval itself succeedsthe command is unblocked and executes correctly.
Only the card UI update fails.

### Affected Component

Gateway (Telegram/Discord/Slack/WhatsApp)

### Messaging Platform (if gateway-related)

_No response_

### Debug Report

```shell
N/Aroot cause identified through code inspection.
See Root Cause Analysis section below.

Operating System

macOS 15.7.4

Python Version

No response

Hermes Version

Hermes Agent v0.8.0 (2026.4.8)

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

No response

Proposed Fix (optional)

N/A — root cause identified through code inspection.
See Root Cause Analysis section below.

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/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