Skip to content

Feishu: send to user open_id fails with [230001] invalid receive_id #9980

@summer-hub

Description

@summer-hub

Bug Description

When sending messages to Feishu users (using open_id format, e.g. ou_245ad75b...) via cron job delivery or manual send, the API returns:

[230001] invalid receive_id

This happens because _send_raw_message in gateway/platforms/feishu.py always uses receive_id_type='chat_id' when creating messages (line 3292):

request = self._build_create_message_request("chat_id", body)

Feishu's im.message.create API requires different receive_id_type values depending on the ID format:

  • User ID (prefix ou_) → receive_id_type should be "open_id"
  • Group ID (prefix oc_) → receive_id_type should be "chat_id"
  • Union ID (prefix on_) → receive_id_type should be "union_id"

Steps to Reproduce

  1. Configure Feishu platform in Hermes
  2. Create a cron job with deliver=feishu:<user_open_id>
  3. Job runs and attempts to deliver result to the user
  4. API returns [230001] invalid receive_id error

Expected Behavior

Messages should be sent successfully to both user open_ids and group chat_ids.

Suggested Fix

Auto-detect receive_id type from the ID prefix in _send_raw_message:

if chat_id.startswith("oc_"):
    receive_id_type = "chat_id"
elif chat_id.startswith("ou_"):
    receive_id_type = "open_id"
elif chat_id.startswith("on_"):
    receive_id_type = "union_id"
else:
    receive_id_type = "open_id"  # default for user IDs

Environment

  • Hermes Agent version: latest
  • Platform: Feishu (websocket mode)

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