larksuite / larksuite/channel-sdk-python
Long threaded reply leaks out of a topic/thread chat: reply_to dropped on chunks after the first
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 16
- Forks
- 8
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 2
Description
Summary
In a Feishu/Lark thread (topic) chat, the tail of a long threaded reply leaks out of the thread into the main chat.
Root cause
lark_channel/channel/outbound/sender.py — OutboundSender._send_text splits a message longer than text_chunk_limit into multiple bodies, but applies reply_to only to the first chunk:
# Only apply `reply_to` to the first chunk; subsequent chunks are
# fresh messages so they all render in the original chat.
effective_reply_to = reply_to if idx == 0 else None
For a normal reply, "fresh messages render in the original chat" holds. But in a thread/topic chat, a message sent without a reply parent does not render in the thread — it drops into the main chat. So with reply_in_thread=True, every chunk after the first leaks out of the thread.
Reproduction
- In a topic-mode group, send a markdown message longer than
text_chunk_limit(default 3500) withSendOpts(reply_to=<root_message_id>, reply_in_thread=True). - Observed: the first chunk is a threaded reply under the root; the remaining chunks appear as top-level messages in the main group.
- Expected: all chunks stay in the thread.
Suggested fix
Keep reply_to on every chunk when threading:
effective_reply_to = reply_to if (idx == 0 or reply_in_thread) else None
Replying each chunk to the same root with reply_in_thread=True keeps all pieces in the thread; non-thread replies keep the current first-chunk-only behavior.
Observed on 1.1.0 and current main (lines ~388–390). A PR with this change is opened separately.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lark_channel/channel/outbound/sender.py at OutboundSender._send_text and inspect how reply_to is applied while messages exceed text_chunk_limit. Reproduce with a topic-mode group and a long markdown message using SendOpts(reply_to=..., reply_in_thread=True); done means every chunk remains in the thread while non-thread replies retain their current behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100