fix(feishu): extract images from post (rich text) messages#1327
fix(feishu): extract images from post (rich text) messages#1327Vast-Stars wants to merge 1 commit intosipeed:mainfrom
Conversation
When users send text+image together in Feishu, the message type is "post" (rich text) instead of "image". The image download logic only handled MsgTypeImage, so images embedded in post messages were silently ignored — the agent received raw JSON instead of actual image content. - Add extractPostImageKeys() to parse img tags from post content - Add extractPostText() to extract plain text from post content - Handle MsgTypePost in downloadInboundMedia to download embedded images - Handle MsgTypePost in appendMediaTags to add [image: photo] tag
nikolasdehor
left a comment
There was a problem hiding this comment.
Well-structured fix for Feishu post (rich text) message image extraction. The changes are clean and well-tested.
Highlights:
-
extractPostImageKeys / extractPostText -- good separation of concerns. The JSON struct parsing is straightforward and handles the nested paragraph/element structure correctly.
-
Graceful degradation --
extractPostTextfalls back torawContenton JSON parse error, whileextractPostImageKeysreturns nil. This asymmetry is intentional and correct: for text, showing raw content is better than nothing; for images, silently skipping malformed data avoids passing garbage keys to the download API. -
Test coverage -- comprehensive: text+image, multiple images, no images, invalid JSON, empty content, title handling. All edge cases I can think of are covered.
-
Minimal change to extractContent -- replacing raw JSON passthrough with
extractPostText()is the right call. The LLM gets clean text, and images are routed through the existingdownloadInboundMediapipeline. -
appendMediaTags update -- the
MsgTypePostaddition to the image tag case is a simple one-liner that correctly reuses existing logic.
LGTM.
yinwm
left a comment
There was a problem hiding this comment.
Review Summary
This PR fixes a real issue where images embedded in Feishu post (rich text) messages were silently ignored.
What I like:
- Clean implementation: The new
extractPostImageKeys()andextractPostText()functions follow the existing code style - Good test coverage: Edge cases are well covered (text+image, multiple images, only images, invalid JSON, empty content)
- Reasonable fallback:
extractPostTextreturns raw content on JSON parse failure, no message loss - No breaking changes: The fix is additive and doesn't affect other message types
Minor observation (not blocking):
The same rawContent is JSON-parsed twice (once in extractPostImageKeys, once in extractPostText). This is a micro-optimization opportunity but acceptable for the current scale.
Suggestion:
Please complete the manual tests in the test plan before merging:
- Manual test: send image-only message in Feishu → agent sees image (regression check)
- Manual test: send text+image message in Feishu → agent now sees both text and image
Approve ✅
|
fix linter plz, @Vast-Stars |
|
@Vast-Stars Hi! This PR has had no activity for over 2 weeks, so I'm closing it for now to keep things tidy. If it's still relevant, feel free to reopen it anytime and we'll pick it back up. |
Summary
post(rich text) instead ofimage. The image download logic only handledMsgTypeImage, so images embedded in post messages were silently ignored — the agent received raw JSON instead of actual image content.extractPostImageKeys()to parseimgtags from post contentextractPostText()to extract plain text from post contentMsgTypePostindownloadInboundMediato download embedded imagesMsgTypePostinappendMediaTagsto add[image: photo]tagTest plan
extractPostImageKeys(text+image, multiple images, no images, invalid JSON)extractPostText(text+image, with title, only images, invalid JSON)TestExtractContentfor post message typeTestAppendMediaTagsfor post message type