fix(feishu): reply-to media injection for image-only parent messages - #29641
Open
rpplusplus wants to merge 1 commit into
Open
fix(feishu): reply-to media injection for image-only parent messages#29641rpplusplus wants to merge 1 commit into
rpplusplus wants to merge 1 commit into
Conversation
## Problem When a user replies to an image-only message (no text), the agent sees `[Replying to: "None"]` and cannot see the original image. Root cause chain: 1. `_fetch_message_text()` calls `_extract_text_from_raw_content()` 2. For image messages, `text_content=""` and `metadata=None` 3. `str(None).strip()` returns `"None"` (the string), not Python `None` 4. `"None" or None` evaluates to `"None"` (truthy string) 5. The string `"None"` is cached and returned as reply_to_text 6. Media from the parent message is never fetched ## Fix - Rename `_fetch_message_text` → `_fetch_reply_context` - Return `(text, media_urls, media_types)` tuple instead of just text - Download images/files from parent message and inject into current message's media - Fix `str(None).strip() or None` → `str(placeholder).strip() if placeholder is not None else None` - When parent has media but no text, set `reply_to_text = "(image)"` - Add debug logging for media download operations - Update all tests to match new API
Collaborator
teknium1
reviewed
Jul 13, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for isolating both the text coercion and missing parent-media paths. The underlying issue is still present on current main: plugins/platforms/feishu/adapter.py:4211 converts a missing placeholder to the literal "None", while :3259 calls a text-only parent lookup.
Problems
- This patch modifies
gateway/platforms/feishu.py, but Feishu now lives atplugins/platforms/feishu/adapter.pyafter552adbe0827c32df8ed9bb19e908c26eff43add7; GitHub reports this PR as conflicting. Current main also uses_run_blockingfor SDK calls atadapter.py:4170. - The changed tests only update mocks and text assertions. They do not exercise an image-only parent, parent-resource download, or the emitted event's
media_urls/media_types.
Suggested changes
- Port the logic to the bundled plugin, reusing
_download_feishu_message_resourcesatplugins/platforms/feishu/adapter.py:3771. - Add an end-to-end adapter-unit regression test for an image-only reply parent and assert no
"None"reply text plus attached parent media.
Automated hermes-sweeper review.
| return_value={"user_id": "ou_user", "user_name": "张三", "user_id_alt": None} | ||
| ) | ||
| adapter._fetch_message_text = AsyncMock(return_value="父消息内容") | ||
| adapter._fetch_reply_context = AsyncMock(return_value=("父消息内容", [], [])) |
Contributor
There was a problem hiding this comment.
Please add a separate regression case for the actual new contract: make the reply-context mock return a parent image path/type and assert the dispatched event contains those values and never exposes reply_to_text == "None". This updated test still exercises only the text-only tuple.
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
When a user replies to an image-only message (no text), the agent sees
[Replying to: "None"]and cannot see the original image.Root Cause Chain
_fetch_message_text()calls_extract_text_from_raw_content()text_content=""andmetadata=Nonestr(None).strip()returns"None"(the string), not PythonNone"None" or Noneevaluates to"None"(truthy string)"None"is cached and returned as reply_to_textLogs Before Fix
Fix
_fetch_message_text→_fetch_reply_context(text, media_urls, media_types)tuple instead of just textstr(None).strip() or None→str(placeholder).strip() if placeholder is not None else Nonereply_to_text = "(image)"What does this PR do?
Fixes a bug where replying to image-only messages in Feishu showed
[Replying to: "None"]instead of passing the original image to the agent. The root cause was a Python type coercion issue wherestr(None)returns the string"None", which is truthy, causing it to be used as the reply text. This PR also adds media downloading from parent messages so the agent can see images being replied to.Related Issue
Fixes the issue described in
feishu-platformskill: "Reply-to for image-only messages returns 'None'"Type of Change
Changes Made
gateway/platforms/feishu.py: Renamed_fetch_message_textto_fetch_reply_context, returns(text, media_urls, media_types)tuple, downloads parent message media, fixedstr(None)bugtests/gateway/test_feishu.py: Updated all mocks and assertions to match new_fetch_reply_contextAPIHow to Test
[Replying to: "None"])Downloaded N media attachment(s) from reply-to messageChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
Before fix:
After fix:
PR Links