Skip to content

fix(feishu): prevent unwanted topic creation on DM quote-reply - #30164

Open
SunmiJJW wants to merge 1 commit into
NousResearch:mainfrom
SunmiJJW:fix/feishu-dm-unwanted-topic
Open

fix(feishu): prevent unwanted topic creation on DM quote-reply#30164
SunmiJJW wants to merge 1 commit into
NousResearch:mainfrom
SunmiJJW:fix/feishu-dm-unwanted-topic

Conversation

@SunmiJJW

@SunmiJJW SunmiJJW commented May 22, 2026

Copy link
Copy Markdown

When a user quotes a message in a Feishu DM (p2p chat), the SDK sets root_id on the inbound message object. Promoting that value to source.thread_id makes outbound replies use reply_in_thread=True, which creates an unwanted Feishu topic on the quoted DM message.

This keeps root_id as quoted-message reply context in DMs while preserving the root_id -> thread_id fallback for group/channel chats.

What does this PR do?

  • Prevents quoted Feishu DM messages from being treated as threaded topic replies.
  • Preserves quoted-message context through reply_to_message_id and reply_to_text.
  • Preserves topic/thread behavior for group/channel chats.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Changes Made

  • plugins/platforms/feishu/adapter.py: skip the root_id -> thread_id fallback for p2p chats.
  • tests/gateway/test_feishu.py: add p2p and group root_id regression coverage.

How to Test

scripts/run_tests.sh -j 1 tests/gateway/test_feishu.py -k "p2p_root_id_keeps_reply_context_without_thread or group_root_id_is_preserved_as_thread" -q
python -m py_compile plugins/platforms/feishu/adapter.py tests/gateway/test_feishu.py
ruff check plugins/platforms/feishu/adapter.py tests/gateway/test_feishu.py

Local results on Windows 11 / Python 3.12:

  • Root-id regression cases: 2 passed, 210 deselected
  • Related inbound-message class: 7 passed, 205 deselected
  • py_compile: passed
  • ruff check: passed

Checklist

Code

  • My commit message follows Conventional Commits.
  • My PR contains only changes related to this fix.
  • I've added regression tests for the bug.
  • I've run the full repository test suite.
  • I've tested on Windows 11 / Python 3.12.

Documentation & Housekeeping

  • Documentation changes are not required.
  • No configuration keys or schemas changed.
  • Cross-platform impact was considered.

@alt-glitch alt-glitch added type/bug Something isn't working platform/feishu Feishu / Lark adapter comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists labels May 22, 2026
@SunmiJJW

Copy link
Copy Markdown
Author

Hi! 👋 Just checking in on this PR.

This fix prevents an unwanted topic from being created when a user quotes a message in Feishu DM (p2p) chats. In DMs, Feishu sets root_id on quoted messages even though there is no native thread/topic support — treating it as thread_id causes reply_in_thread=True, which triggers the API to create a topic on the quoted message.

The fix adds a simple chat_type == "p2p" guard so that root_id is only used as thread_id fallback in group/channel chats, where topics are actually supported.

Happy to make any adjustments if needed. Thanks for your time! 🙏

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused Feishu report and narrow fix. The underlying root_id promotion is still present on current main, but the adapter moved after this PR was opened.

Problems

  • The submitted edit targets gateway/platforms/feishu.py, which was migrated to plugins/platforms/feishu/adapter.py by 5600105478ffde29d7566b45421b100eaa29c4ef. Current behavior is at plugins/platforms/feishu/adapter.py:3252, and the PR is currently DIRTY against main.
  • This bug fix has no regression test. The existing reply-context test at tests/gateway/test_feishu.py:2069 covers parent_id, but not a p2p root_id that must remain reply context without becoming source.thread_id.

Suggested changes

  • Port the guard to plugins/platforms/feishu/adapter.py:3252, leaving reply_to_message_id handling at lines 3253-3258 intact.
  • Add p2p and group/channel root_id regression cases: p2p should not set source.thread_id; group/channel should preserve the fallback.

Automated hermes-sweeper review.

Comment thread gateway/platforms/feishu.py Outdated
@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:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 13, 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-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades 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.

3 participants