fix(feishu): Remove incorrect oc_ prefix assumption in resolveFeishuSession#10407
Conversation
Additional Comments (1)
The comment block above Prompt To Fix With AIThis is a comment left during a code review.
Path: src/infra/outbound/outbound-session.ts
Line: 819:825
Comment:
**Incorrect Feishu ID docs**
The comment block above `resolveFeishuSession` still states `oc_xxx` is a group chat ID, but this PR’s behavior (and Feishu’s API) treats `oc_` as a generic `chat_id` that can be either group or p2p. This mismatch will mislead future changes and reviewers. Update the comment to reflect that `oc_` can be DM or group (and requires explicit prefix / API `chat_mode` to disambiguate).
How can I resolve this? If you propose a fix, please make it concise. |
|
when will this merge complete |
|
Hi @joshp123, this PR fixes a bug in the It's a small, localized fix (one file) and has been approved. The CI failure (macOS swiftlint) is unrelated. Would love your review since you handled the original Feishu integration. Thanks! 🙏 |
2bfba0f to
42a814f
Compare
bfc1ccb to
f92900f
Compare
|
This pull request has been automatically marked as stale due to inactivity. |
…ession - Feishu oc_ is a generic chat_id that can represent both groups and DMs - Must use chat_mode field from API to distinguish, not ID prefix - Only ou_/on_ prefixes reliably indicate user IDs (always DM) - Fixes session misrouting for DMs with oc_ chat IDs This bug caused DM messages with oc_ chat_ids to be incorrectly created as group sessions, breaking session isolation and routing.
The previous comment incorrectly stated oc_ is always a group chat. This update clarifies that oc_ chat_ids can be either groups or DMs, and explicit prefixes (dm:/group:) should be used to distinguish.
a6d8952 to
c6b8cd2
Compare
…ession (openclaw#10407) * fix(feishu): remove incorrect oc_ prefix assumption in resolveFeishuSession - Feishu oc_ is a generic chat_id that can represent both groups and DMs - Must use chat_mode field from API to distinguish, not ID prefix - Only ou_/on_ prefixes reliably indicate user IDs (always DM) - Fixes session misrouting for DMs with oc_ chat IDs This bug caused DM messages with oc_ chat_ids to be incorrectly created as group sessions, breaking session isolation and routing. * docs: update Feishu ID format comment to reflect oc_ ambiguity The previous comment incorrectly stated oc_ is always a group chat. This update clarifies that oc_ chat_ids can be either groups or DMs, and explicit prefixes (dm:/group:) should be used to distinguish. * feishu: add regression coverage for oc session routing --------- Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…ession (openclaw#10407) * fix(feishu): remove incorrect oc_ prefix assumption in resolveFeishuSession - Feishu oc_ is a generic chat_id that can represent both groups and DMs - Must use chat_mode field from API to distinguish, not ID prefix - Only ou_/on_ prefixes reliably indicate user IDs (always DM) - Fixes session misrouting for DMs with oc_ chat IDs This bug caused DM messages with oc_ chat_ids to be incorrectly created as group sessions, breaking session isolation and routing. * docs: update Feishu ID format comment to reflect oc_ ambiguity The previous comment incorrectly stated oc_ is always a group chat. This update clarifies that oc_ chat_ids can be either groups or DMs, and explicit prefixes (dm:/group:) should be used to distinguish. * feishu: add regression coverage for oc session routing --------- Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…ession (openclaw#10407) * fix(feishu): remove incorrect oc_ prefix assumption in resolveFeishuSession - Feishu oc_ is a generic chat_id that can represent both groups and DMs - Must use chat_mode field from API to distinguish, not ID prefix - Only ou_/on_ prefixes reliably indicate user IDs (always DM) - Fixes session misrouting for DMs with oc_ chat IDs This bug caused DM messages with oc_ chat_ids to be incorrectly created as group sessions, breaking session isolation and routing. * docs: update Feishu ID format comment to reflect oc_ ambiguity The previous comment incorrectly stated oc_ is always a group chat. This update clarifies that oc_ chat_ids can be either groups or DMs, and explicit prefixes (dm:/group:) should be used to distinguish. * feishu: add regression coverage for oc session routing --------- Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…ession (openclaw#10407) * fix(feishu): remove incorrect oc_ prefix assumption in resolveFeishuSession - Feishu oc_ is a generic chat_id that can represent both groups and DMs - Must use chat_mode field from API to distinguish, not ID prefix - Only ou_/on_ prefixes reliably indicate user IDs (always DM) - Fixes session misrouting for DMs with oc_ chat IDs This bug caused DM messages with oc_ chat_ids to be incorrectly created as group sessions, breaking session isolation and routing. * docs: update Feishu ID format comment to reflect oc_ ambiguity The previous comment incorrectly stated oc_ is always a group chat. This update clarifies that oc_ chat_ids can be either groups or DMs, and explicit prefixes (dm:/group:) should be used to distinguish. * feishu: add regression coverage for oc session routing --------- Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com> (cherry picked from commit 1274b6f)
…ession (openclaw#10407) * fix(feishu): remove incorrect oc_ prefix assumption in resolveFeishuSession - Feishu oc_ is a generic chat_id that can represent both groups and DMs - Must use chat_mode field from API to distinguish, not ID prefix - Only ou_/on_ prefixes reliably indicate user IDs (always DM) - Fixes session misrouting for DMs with oc_ chat IDs This bug caused DM messages with oc_ chat_ids to be incorrectly created as group sessions, breaking session isolation and routing. * docs: update Feishu ID format comment to reflect oc_ ambiguity The previous comment incorrectly stated oc_ is always a group chat. This update clarifies that oc_ chat_ids can be either groups or DMs, and explicit prefixes (dm:/group:) should be used to distinguish. * feishu: add regression coverage for oc session routing --------- Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com> (cherry picked from commit 1274b6f)
…ession (openclaw#10407) * fix(feishu): remove incorrect oc_ prefix assumption in resolveFeishuSession - Feishu oc_ is a generic chat_id that can represent both groups and DMs - Must use chat_mode field from API to distinguish, not ID prefix - Only ou_/on_ prefixes reliably indicate user IDs (always DM) - Fixes session misrouting for DMs with oc_ chat IDs This bug caused DM messages with oc_ chat_ids to be incorrectly created as group sessions, breaking session isolation and routing. * docs: update Feishu ID format comment to reflect oc_ ambiguity The previous comment incorrectly stated oc_ is always a group chat. This update clarifies that oc_ chat_ids can be either groups or DMs, and explicit prefixes (dm:/group:) should be used to distinguish. * feishu: add regression coverage for oc session routing --------- Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com> (cherry picked from commit 1274b6f)
…ession (openclaw#10407) * fix(feishu): remove incorrect oc_ prefix assumption in resolveFeishuSession - Feishu oc_ is a generic chat_id that can represent both groups and DMs - Must use chat_mode field from API to distinguish, not ID prefix - Only ou_/on_ prefixes reliably indicate user IDs (always DM) - Fixes session misrouting for DMs with oc_ chat IDs This bug caused DM messages with oc_ chat_ids to be incorrectly created as group sessions, breaking session isolation and routing. * docs: update Feishu ID format comment to reflect oc_ ambiguity The previous comment incorrectly stated oc_ is always a group chat. This update clarifies that oc_ chat_ids can be either groups or DMs, and explicit prefixes (dm:/group:) should be used to distinguish. * feishu: add regression coverage for oc session routing --------- Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…ession (openclaw#10407) * fix(feishu): remove incorrect oc_ prefix assumption in resolveFeishuSession - Feishu oc_ is a generic chat_id that can represent both groups and DMs - Must use chat_mode field from API to distinguish, not ID prefix - Only ou_/on_ prefixes reliably indicate user IDs (always DM) - Fixes session misrouting for DMs with oc_ chat IDs This bug caused DM messages with oc_ chat_ids to be incorrectly created as group sessions, breaking session isolation and routing. * docs: update Feishu ID format comment to reflect oc_ ambiguity The previous comment incorrectly stated oc_ is always a group chat. This update clarifies that oc_ chat_ids can be either groups or DMs, and explicit prefixes (dm:/group:) should be used to distinguish. * feishu: add regression coverage for oc session routing --------- Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…ession (openclaw#10407) * fix(feishu): remove incorrect oc_ prefix assumption in resolveFeishuSession - Feishu oc_ is a generic chat_id that can represent both groups and DMs - Must use chat_mode field from API to distinguish, not ID prefix - Only ou_/on_ prefixes reliably indicate user IDs (always DM) - Fixes session misrouting for DMs with oc_ chat IDs This bug caused DM messages with oc_ chat_ids to be incorrectly created as group sessions, breaking session isolation and routing. * docs: update Feishu ID format comment to reflect oc_ ambiguity The previous comment incorrectly stated oc_ is always a group chat. This update clarifies that oc_ chat_ids can be either groups or DMs, and explicit prefixes (dm:/group:) should be used to distinguish. * feishu: add regression coverage for oc session routing --------- Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…ession (openclaw#10407) * fix(feishu): remove incorrect oc_ prefix assumption in resolveFeishuSession - Feishu oc_ is a generic chat_id that can represent both groups and DMs - Must use chat_mode field from API to distinguish, not ID prefix - Only ou_/on_ prefixes reliably indicate user IDs (always DM) - Fixes session misrouting for DMs with oc_ chat IDs This bug caused DM messages with oc_ chat_ids to be incorrectly created as group sessions, breaking session isolation and routing. * docs: update Feishu ID format comment to reflect oc_ ambiguity The previous comment incorrectly stated oc_ is always a group chat. This update clarifies that oc_ chat_ids can be either groups or DMs, and explicit prefixes (dm:/group:) should be used to distinguish. * feishu: add regression coverage for oc session routing --------- Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…ession (openclaw#10407) * fix(feishu): remove incorrect oc_ prefix assumption in resolveFeishuSession - Feishu oc_ is a generic chat_id that can represent both groups and DMs - Must use chat_mode field from API to distinguish, not ID prefix - Only ou_/on_ prefixes reliably indicate user IDs (always DM) - Fixes session misrouting for DMs with oc_ chat IDs This bug caused DM messages with oc_ chat_ids to be incorrectly created as group sessions, breaking session isolation and routing. * docs: update Feishu ID format comment to reflect oc_ ambiguity The previous comment incorrectly stated oc_ is always a group chat. This update clarifies that oc_ chat_ids can be either groups or DMs, and explicit prefixes (dm:/group:) should be used to distinguish. * feishu: add regression coverage for oc session routing --------- Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…ession (openclaw#10407) * fix(feishu): remove incorrect oc_ prefix assumption in resolveFeishuSession - Feishu oc_ is a generic chat_id that can represent both groups and DMs - Must use chat_mode field from API to distinguish, not ID prefix - Only ou_/on_ prefixes reliably indicate user IDs (always DM) - Fixes session misrouting for DMs with oc_ chat IDs This bug caused DM messages with oc_ chat_ids to be incorrectly created as group sessions, breaking session isolation and routing. * docs: update Feishu ID format comment to reflect oc_ ambiguity The previous comment incorrectly stated oc_ is always a group chat. This update clarifies that oc_ chat_ids can be either groups or DMs, and explicit prefixes (dm:/group:) should be used to distinguish. * feishu: add regression coverage for oc session routing --------- Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…ession (openclaw#10407) * fix(feishu): remove incorrect oc_ prefix assumption in resolveFeishuSession - Feishu oc_ is a generic chat_id that can represent both groups and DMs - Must use chat_mode field from API to distinguish, not ID prefix - Only ou_/on_ prefixes reliably indicate user IDs (always DM) - Fixes session misrouting for DMs with oc_ chat IDs This bug caused DM messages with oc_ chat_ids to be incorrectly created as group sessions, breaking session isolation and routing. * docs: update Feishu ID format comment to reflect oc_ ambiguity The previous comment incorrectly stated oc_ is always a group chat. This update clarifies that oc_ chat_ids can be either groups or DMs, and explicit prefixes (dm:/group:) should be used to distinguish. * feishu: add regression coverage for oc session routing --------- Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…ession (openclaw#10407) * fix(feishu): remove incorrect oc_ prefix assumption in resolveFeishuSession - Feishu oc_ is a generic chat_id that can represent both groups and DMs - Must use chat_mode field from API to distinguish, not ID prefix - Only ou_/on_ prefixes reliably indicate user IDs (always DM) - Fixes session misrouting for DMs with oc_ chat IDs This bug caused DM messages with oc_ chat_ids to be incorrectly created as group sessions, breaking session isolation and routing. * docs: update Feishu ID format comment to reflect oc_ ambiguity The previous comment incorrectly stated oc_ is always a group chat. This update clarifies that oc_ chat_ids can be either groups or DMs, and explicit prefixes (dm:/group:) should be used to distinguish. * feishu: add regression coverage for oc session routing --------- Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…ession (openclaw#10407) * fix(feishu): remove incorrect oc_ prefix assumption in resolveFeishuSession - Feishu oc_ is a generic chat_id that can represent both groups and DMs - Must use chat_mode field from API to distinguish, not ID prefix - Only ou_/on_ prefixes reliably indicate user IDs (always DM) - Fixes session misrouting for DMs with oc_ chat IDs This bug caused DM messages with oc_ chat_ids to be incorrectly created as group sessions, breaking session isolation and routing. * docs: update Feishu ID format comment to reflect oc_ ambiguity The previous comment incorrectly stated oc_ is always a group chat. This update clarifies that oc_ chat_ids can be either groups or DMs, and explicit prefixes (dm:/group:) should be used to distinguish. * feishu: add regression coverage for oc session routing --------- Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…ession (openclaw#10407) * fix(feishu): remove incorrect oc_ prefix assumption in resolveFeishuSession - Feishu oc_ is a generic chat_id that can represent both groups and DMs - Must use chat_mode field from API to distinguish, not ID prefix - Only ou_/on_ prefixes reliably indicate user IDs (always DM) - Fixes session misrouting for DMs with oc_ chat IDs This bug caused DM messages with oc_ chat_ids to be incorrectly created as group sessions, breaking session isolation and routing. * docs: update Feishu ID format comment to reflect oc_ ambiguity The previous comment incorrectly stated oc_ is always a group chat. This update clarifies that oc_ chat_ids can be either groups or DMs, and explicit prefixes (dm:/group:) should be used to distinguish. * feishu: add regression coverage for oc session routing --------- Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…ession (openclaw#10407) * fix(feishu): remove incorrect oc_ prefix assumption in resolveFeishuSession - Feishu oc_ is a generic chat_id that can represent both groups and DMs - Must use chat_mode field from API to distinguish, not ID prefix - Only ou_/on_ prefixes reliably indicate user IDs (always DM) - Fixes session misrouting for DMs with oc_ chat IDs This bug caused DM messages with oc_ chat_ids to be incorrectly created as group sessions, breaking session isolation and routing. * docs: update Feishu ID format comment to reflect oc_ ambiguity The previous comment incorrectly stated oc_ is always a group chat. This update clarifies that oc_ chat_ids can be either groups or DMs, and explicit prefixes (dm:/group:) should be used to distinguish. * feishu: add regression coverage for oc session routing --------- Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…ession (openclaw#10407) * fix(feishu): remove incorrect oc_ prefix assumption in resolveFeishuSession - Feishu oc_ is a generic chat_id that can represent both groups and DMs - Must use chat_mode field from API to distinguish, not ID prefix - Only ou_/on_ prefixes reliably indicate user IDs (always DM) - Fixes session misrouting for DMs with oc_ chat IDs This bug caused DM messages with oc_ chat_ids to be incorrectly created as group sessions, breaking session isolation and routing. * docs: update Feishu ID format comment to reflect oc_ ambiguity The previous comment incorrectly stated oc_ is always a group chat. This update clarifies that oc_ chat_ids can be either groups or DMs, and explicit prefixes (dm:/group:) should be used to distinguish. * feishu: add regression coverage for oc session routing --------- Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…ession (openclaw#10407) * fix(feishu): remove incorrect oc_ prefix assumption in resolveFeishuSession - Feishu oc_ is a generic chat_id that can represent both groups and DMs - Must use chat_mode field from API to distinguish, not ID prefix - Only ou_/on_ prefixes reliably indicate user IDs (always DM) - Fixes session misrouting for DMs with oc_ chat IDs This bug caused DM messages with oc_ chat_ids to be incorrectly created as group sessions, breaking session isolation and routing. * docs: update Feishu ID format comment to reflect oc_ ambiguity The previous comment incorrectly stated oc_ is always a group chat. This update clarifies that oc_ chat_ids can be either groups or DMs, and explicit prefixes (dm:/group:) should be used to distinguish. * feishu: add regression coverage for oc session routing --------- Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…ession (openclaw#10407) * fix(feishu): remove incorrect oc_ prefix assumption in resolveFeishuSession - Feishu oc_ is a generic chat_id that can represent both groups and DMs - Must use chat_mode field from API to distinguish, not ID prefix - Only ou_/on_ prefixes reliably indicate user IDs (always DM) - Fixes session misrouting for DMs with oc_ chat IDs This bug caused DM messages with oc_ chat_ids to be incorrectly created as group sessions, breaking session isolation and routing. * docs: update Feishu ID format comment to reflect oc_ ambiguity The previous comment incorrectly stated oc_ is always a group chat. This update clarifies that oc_ chat_ids can be either groups or DMs, and explicit prefixes (dm:/group:) should be used to distinguish. * feishu: add regression coverage for oc session routing --------- Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…ession (openclaw#10407) * fix(feishu): remove incorrect oc_ prefix assumption in resolveFeishuSession - Feishu oc_ is a generic chat_id that can represent both groups and DMs - Must use chat_mode field from API to distinguish, not ID prefix - Only ou_/on_ prefixes reliably indicate user IDs (always DM) - Fixes session misrouting for DMs with oc_ chat IDs This bug caused DM messages with oc_ chat_ids to be incorrectly created as group sessions, breaking session isolation and routing. * docs: update Feishu ID format comment to reflect oc_ ambiguity The previous comment incorrectly stated oc_ is always a group chat. This update clarifies that oc_ chat_ids can be either groups or DMs, and explicit prefixes (dm:/group:) should be used to distinguish. * feishu: add regression coverage for oc session routing --------- Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…ession (openclaw#10407) * fix(feishu): remove incorrect oc_ prefix assumption in resolveFeishuSession - Feishu oc_ is a generic chat_id that can represent both groups and DMs - Must use chat_mode field from API to distinguish, not ID prefix - Only ou_/on_ prefixes reliably indicate user IDs (always DM) - Fixes session misrouting for DMs with oc_ chat IDs This bug caused DM messages with oc_ chat_ids to be incorrectly created as group sessions, breaking session isolation and routing. * docs: update Feishu ID format comment to reflect oc_ ambiguity The previous comment incorrectly stated oc_ is always a group chat. This update clarifies that oc_ chat_ids can be either groups or DMs, and explicit prefixes (dm:/group:) should be used to distinguish. * feishu: add regression coverage for oc session routing --------- Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
Fix Feishu
oc_prefix assumption causing DM misrouting🐛 Problem
resolveFeishuSessionincorrectly assumes alloc_prefixed IDs are group chats. However, Feishu'soc_is a generic chat_id that can represent both groups and DMs (p2p chats).📊 Impact
oc_chat_ids are misrouted as group sessions🔍 Evidence
Verified with Feishu API queries:
oc_19dd...chat_mode: "p2p"(DM)oc_724b...chat_mode: "group"Root cause: The code incorrectly assumes ID prefix determines type, but Feishu uses the same
oc_prefix for both groups and DMs.🛠 Solution
Before:
After:
Key changes:
typeExplicitflag to track explicit type specificationoc_→ group assumptionou_/on_→ DM inference (these are user IDs, always DM)oc_IDs now require explicitdm:orgroup:prefix✅ Testing
Tested with real Feishu environment:
oc_chat_id correctly routes to DM sessionoc_chat_id correctly routes to group sessiondm:oc_xxx,group:oc_xxx) work correctlyou_,on_) still infer as DM📚 Context
Feishu's ID format:
oc_: chat_id (generic, can be group or DM - needschat_modeto distinguish)ou_: user open_id (always DM)on_: user union_id (always DM)The correct approach is to either:
chat_modefield from Feishu API response (for incoming messages) ✅dm:orgroup:) ✅This PR implements approach #2 for
resolveFeishuSession(outbound routing).Bare
oc_without an explicit prefix now defaults to DM (isGroup=false).This is a safer default than the previous behavior (always group), as
misrouting a group message to a DM session has a smaller blast radius
than the reverse — a DM session leaking into a group context is a worse
outcome from both a privacy and UX perspective.
For outbound routing (e.g. message tool, cron delivery), callers should
use explicit prefixes:
group:oc_xxxordm:oc_xxx.🔮 Future improvement
Auto-detection of
oc_chat type (e.g. via session store lookup orFeishu Chat API query) could eliminate the need for explicit prefixes
entirely. This is out of scope for this fix but tracked in #12658.
🔗 Related
First-time contributor here! 👋 Found this bug while using OpenClaw's Feishu integration and verified with API calls. Happy to make any adjustments based on feedback.
Greptile Overview
Greptile Summary
oc_IDs are group chats.typeExplicitflag sogroup:/chat:vsdm:/user:prefixes take precedence over ID-prefix heuristics.ou_/on_inference as DM-only when no explicit type is provided, avoiding DM/group session key collisions for Feishu chat_ids.Confidence Score: 4/5
(2/5) Greptile learns from your feedback when you react with thumbs up/down!