Skip to content

fix: auto-detect Feishu receive_id_type from ID prefix - #10040

Open
nightq wants to merge 2 commits into
NousResearch:mainfrom
nightq:fix/issue-9980-feishu-receive-id
Open

fix: auto-detect Feishu receive_id_type from ID prefix#10040
nightq wants to merge 2 commits into
NousResearch:mainfrom
nightq:fix/issue-9980-feishu-receive-id

Conversation

@nightq

@nightq nightq commented Apr 15, 2026

Copy link
Copy Markdown

Summary

Fixes Feishu message delivery failing with [230001] invalid receive_id when sending to user open_ids (ou_) or union_ids (on_).

Root Cause

_send_raw_message() hardcoded receive_id_type='chat_id' for all messages. Feishu's API requires different receive_id_type values based on the ID format:

  • User ID (ou_) → open_id
  • Group ID (oc_) → chat_id
  • Union ID (on_) → union_id

Fix

Added _detect_receive_id_type() static method that auto-detects the correct type from the ID prefix, and integrated it into _send_raw_message().

Test Plan

  • 5 new unit tests for all ID prefix variants
  • Existing Feishu tests still pass

Closes #9980

nightq added 2 commits April 15, 2026 11:41
Fixes NousResearch#9999

Root cause: _sanitize_api_messages compared raw tool_call_id strings
without stripping whitespace, causing valid tool results to be treated
as orphaned when IDs had leading/trailing spaces.
Fix: strip whitespace in _get_tool_call_id_static and when collecting
result_call_ids from tool messages.
Fixes NousResearch#9980

Root cause: _send_raw_message hardcoded 'chat_id' as receive_id_type,
causing [230001] invalid receive_id errors when sending to user open_ids
(prefix 'ou_') or union_ids (prefix 'on_').
Fix: Add _detect_receive_id_type() that checks ID prefix (oc_→chat_id,
ou_→open_id, on_→union_id) and use it in _send_raw_message.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists platform/feishu Feishu / Lark adapter comp/gateway Gateway runner, session dispatch, delivery labels Apr 26, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #7769 — same fix: auto-detect Feishu receive_id_type from ID prefix. Also related to #13725 which bundles the same fix.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for identifying the Feishu recipient-type issue. The open-ID part is already present on current main, but the union-ID part remains valid.

Problems

  • The PR edits gateway/platforms/feishu.py, but commit 5600105478ffde29d7566b45421b100eaa29c4ef moved the live adapter to plugins/platforms/feishu/adapter.py; the patch cannot apply directly.
  • Current main maps ou_ to open_id at plugins/platforms/feishu/adapter.py:4641-4642, but on_ still falls through from the chat_id default at :4637 to request creation at :4650.
  • The proposed helper tests do not exercise the actual send request path. Existing request-capture tests at tests/gateway/test_feishu.py:2039-2078 provide the appropriate pattern.
  • The separate whitespace sanitizer change and its tests already exist on main at run_agent.py:3673-3677, agent/agent_runtime_helpers.py:2531-2543, and tests/run_agent/test_agent_guardrails.py:111-133.

Suggested changes

  • Salvage only an on_union_id branch into the active plugin adapter, preserving feishu_user_id:, ou_, thread, and group paths.
  • Add a request-level on_ regression test using the current adapter test pattern.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:blast-broad Sweeper blast radius: broad — a core path most sessions hit labels Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/feishu Feishu / Lark adapter sweeper:blast-broad Sweeper blast radius: broad — a core path most sessions hit sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants