hermes - 💡(How to fix) Fix fix(feishu): Card action callback routing issues - invalid message_id and unrecognized /card command [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

Error 1: Invalid message_id

Error 2: Unrecognized /card command

  1. Line 2803: synthetic_text = f"/card {action_tag}" creates a text starting with /, which the gateway's message handler (line 3028-3029) detects and converts back to MessageType.COMMAND, causing the "unrecognized command" error.

Root Cause

In gateway/platforms/feishu.py, function _handle_card_action_event (line ~2783):

  1. Line 2827: message_id=token or str(uuid.uuid4()) uses the card callback token instead of extracting open_message_id from the event context.

  2. Line 2803: synthetic_text = f"/card {action_tag}" creates a text starting with /, which the gateway's message handler (line 3028-3029) detects and converts back to MessageType.COMMAND, causing the "unrecognized command" error.

Fix Action

Fixed

Code Example

Send failed: [99992354] The request you send is not a valid {open_message_id} or not exists
Invalid ids: [c-3248f06911ab0b2b05b4464cbba4fc55635b32c0]

---

Unknown command /card. Type /commands to see what's available, or resend without the leading slash to send as a regular message.

---

# Extract open_message_id from context
context = getattr(event, "context", None)
chat_id = str(getattr(context, "open_chat_id", "") or "")
message_id = str(getattr(context, "open_message_id", "") or "")  # ADD THIS

# Use message_id instead of token
synthetic_event = MessageEvent(
    text=synthetic_text,
    message_type=MessageType.TEXT,  # Change from COMMAND to TEXT
    source=source,
    raw_message=data,
    message_id=message_id or token or str(uuid.uuid4()),  # Use message_id first
    timestamp=datetime.now(),
)

# Change synthetic text prefix to avoid command detection
synthetic_text = f"[card_action] {action_tag}"  # Instead of "/card {action_tag}"
RAW_BUFFERClick to expand / collapse

Bug Description

Feishu card action callbacks have two issues that prevent interactive card buttons from working properly (except for approval buttons which use a separate code path).

Steps to Reproduce

  1. Configure a Feishu app with card action callback (card.action.trigger)
  2. Send an interactive card with buttons via the bot
  3. Click any non-approval button on the card

Expected Behavior

The card button click should be processed by the agent as a message.

Actual Behavior

Two errors occur:

Error 1: Invalid message_id

The gateway uses the card callback token (e.g., c-3248f06911ab...) as the message_id when trying to reply, but this is not a valid Feishu message_id. The actual message_id should be extracted from context.open_message_id.

Send failed: [99992354] The request you send is not a valid {open_message_id} or not exists
Invalid ids: [c-3248f06911ab0b2b05b4464cbba4fc55635b32c0]

Error 2: Unrecognized /card command

Card actions are routed as synthetic /card commands, but this command is not registered in GATEWAY_KNOWN_COMMANDS. The gateway rejects it with:

Unknown command /card. Type /commands to see what's available, or resend without the leading slash to send as a regular message.

Root Cause

In gateway/platforms/feishu.py, function _handle_card_action_event (line ~2783):

  1. Line 2827: message_id=token or str(uuid.uuid4()) uses the card callback token instead of extracting open_message_id from the event context.

  2. Line 2803: synthetic_text = f"/card {action_tag}" creates a text starting with /, which the gateway's message handler (line 3028-3029) detects and converts back to MessageType.COMMAND, causing the "unrecognized command" error.

Proposed Fix

# Extract open_message_id from context
context = getattr(event, "context", None)
chat_id = str(getattr(context, "open_chat_id", "") or "")
message_id = str(getattr(context, "open_message_id", "") or "")  # ADD THIS

# Use message_id instead of token
synthetic_event = MessageEvent(
    text=synthetic_text,
    message_type=MessageType.TEXT,  # Change from COMMAND to TEXT
    source=source,
    raw_message=data,
    message_id=message_id or token or str(uuid.uuid4()),  # Use message_id first
    timestamp=datetime.now(),
)

# Change synthetic text prefix to avoid command detection
synthetic_text = f"[card_action] {action_tag}"  # Instead of "/card {action_tag}"

Environment

  • Hermes Agent version: latest (git main branch)
  • Platform: Feishu/Lark gateway
  • Connection mode: WebSocket (long connection)

Additional Context

  • Approval buttons (Allow Once / Session / Always / Deny) work correctly because they use a separate code path (_handle_approval_card_action) that doesn't have these issues.
  • The fix has been tested locally and works correctly.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING