Skip to content

fix(feishu): extract images from post (rich text) messages#1327

Closed
Vast-Stars wants to merge 1 commit intosipeed:mainfrom
Vast-Stars:bugfix/feishu-post-image
Closed

fix(feishu): extract images from post (rich text) messages#1327
Vast-Stars wants to merge 1 commit intosipeed:mainfrom
Vast-Stars:bugfix/feishu-post-image

Conversation

@Vast-Stars
Copy link
Copy Markdown
Contributor

Summary

  • 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

Test plan

  • Unit tests for extractPostImageKeys (text+image, multiple images, no images, invalid JSON)
  • Unit tests for extractPostText (text+image, with title, only images, invalid JSON)
  • Updated TestExtractContent for post message type
  • Updated TestAppendMediaTags for post message type
  • 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

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
@sipeed-bot sipeed-bot bot added type: bug Something isn't working domain: channel go Pull requests that update go code labels Mar 10, 2026
Copy link
Copy Markdown

@nikolasdehor nikolasdehor left a comment

Choose a reason for hiding this comment

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

Well-structured fix for Feishu post (rich text) message image extraction. The changes are clean and well-tested.

Highlights:

  1. extractPostImageKeys / extractPostText -- good separation of concerns. The JSON struct parsing is straightforward and handles the nested paragraph/element structure correctly.

  2. Graceful degradation -- extractPostText falls back to rawContent on JSON parse error, while extractPostImageKeys returns 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.

  3. Test coverage -- comprehensive: text+image, multiple images, no images, invalid JSON, empty content, title handling. All edge cases I can think of are covered.

  4. 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 existing downloadInboundMedia pipeline.

  5. appendMediaTags update -- the MsgTypePost addition to the image tag case is a simple one-liner that correctly reuses existing logic.

LGTM.

Copy link
Copy Markdown
Collaborator

@yinwm yinwm left a comment

Choose a reason for hiding this comment

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

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() and extractPostText() 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: extractPostText returns 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

@yinwm
Copy link
Copy Markdown
Collaborator

yinwm commented Mar 11, 2026

fix linter plz, @Vast-Stars

xuwei-xy pushed a commit to xuwei-xy/picoclaw that referenced this pull request Mar 14, 2026
@sipeed-bot
Copy link
Copy Markdown

sipeed-bot bot commented Mar 26, 2026

@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.

@sipeed-bot sipeed-bot bot closed this Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: channel go Pull requests that update go code type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants