fix(feishu): add delivery observability and root_id fallback#16131
Closed
highland0971 wants to merge 1 commit into
Closed
fix(feishu): add delivery observability and root_id fallback#16131highland0971 wants to merge 1 commit into
highland0971 wants to merge 1 commit into
Conversation
19 tasks
Three fixes for silent message drop in Feishu adapter:
1. stream_consumer: log send failures instead of silently swallowing them
- When adapter.send() returns success=False, we now log a warning
with chat_id, reply_to, error details, and content length
- Previously these failures were invisible — no log, no retry, no alert
2. feishu.py: add root_id fallback for thread_id resolution
- Some Feishu message events provide root_id but not thread_id
- Without this fallback, topic replies could fail to route correctly
3. feishu.py: add delivery logging to send() and _finalize_send_result()
- send() now logs each chunk with chat_id, reply_to, msg_type, sizes
- _finalize_send_result() logs success (with msg_id) or failure
(with API code and error message)
- This makes silent drops diagnosable from gateway logs
Root cause: messages could be dropped at multiple points in the
delivery chain with zero observability. The stream consumer's
_send_new_chunk silently returned on failure, and the feishu adapter
never logged successful or failed sends. Combined, a dropped message
left absolutely no trace in any log file.
659913b to
3131f29
Compare
Contributor
|
The |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Messages sent via the Feishu adapter could be silently dropped with zero observability — no error log, no warning, no trace. This made it impossible to diagnose why a message never reached the user.
Root Cause
Two gaps in the delivery chain combined to create a black hole:
stream_consumer.py_send_new_chunk(): Whenadapter.send()returnssuccess=False, the method silently sets_edit_supported = Falseand returnsreply_to_id— no log, no retry, no alert. Any failed send is completely invisible.feishu.pysend()and_finalize_send_result(): Neither the send attempt nor its result were ever logged. A failed API call (e.g. invalid post payload, rate limit, permission error) would returnSendResult(success=False)which the stream consumer then silently swallowed.feishu.pythread_id resolution: Some Feishu message events provideroot_idbut notthread_id. Without theroot_idfallback, topic replies could fail to route correctly — another silent failure path.Fix
1.
stream_consumer.py— Log send failures2.
feishu.py— Add delivery logging tosend()Each chunk send now logs: chat_id, reply_to, chunk index, msg_type, payload_len, content_len.
3.
feishu.py— Add result logging to_finalize_send_result()logger.info("[Feishu] send succeeded: msg_id=%s", msg_id)logger.warning("[Feishu] send failed: code=%s msg=%s", code, msg)4.
feishu.py— Addroot_idfallback forthread_idImpact
root_idfallback fixes a known issue where Feishu topic replies could fail to route whenthread_idis not present in the message eventTesting
py_compile.compile()for both filescode:0main