Skip to content

fix(feishu): _send_raw_message hardcodes receive_id_type="chat_id", breaks delivery to open_id (ou_) targets #7685

@lauzhihao

Description

@lauzhihao

Bug

_send_raw_message() in gateway/platforms/feishu.py (line 3220) hardcodes receive_id_type as "chat_id":

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

When cron job delivery targets a user's open_id (prefix ou_), Feishu API rejects it with:

[230001] Your request contains an invalid request parameter, ext=invalid receive_id

Because ou_xxx is not a valid chat_idit's an open_id, and requires receive_id_type="open_id".

Expected

receive_id_type should be inferred from the ID prefix:

┌────────┬──────────┬─────────────────┐
│ PrefixTypereceive_id_type │
├────────┼──────────┼─────────────────┤
│ ou_open_idopen_id         │
├────────┼──────────┼─────────────────┤
│ on_union_idunion_id        │
├────────┼──────────┼─────────────────┤
│ oc_chat_idchat_id         │
└────────┴──────────┴─────────────────┘

Suggested Fix

if chat_id.startswith("ou_"):
    rid_type = "open_id"
elif chat_id.startswith("on_"):
    rid_type = "union_id"
else:
    rid_type = "chat_id"
request = self._build_create_message_request(rid_type, body)

Reproduce

1. Create a cron job with deliver: "feishu:ou_xxxxx"
2. Job executes successfully but delivery fails with invalid receive_id
3. Group targets (oc_) work fine since they match the hardcoded "chat_id" type

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