Repository navigation
🐛 stop dropping received card messages - #179
Merged
Merged
Conversation
Message.deserialize passed the received content to the segment builders as arguments. Received cards and divider system messages have fields the builders do not accept, so it raised TypeError before any matcher ran and the event was lost. Any field Feishu adds later would have done the same.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #179 +/- ##
==========================================
+ Coverage 83.82% 89.19% +5.36%
==========================================
Files 15 11 -4
Lines 1719 1499 -220
==========================================
- Hits 1441 1337 -104
+ Misses 278 162 -116
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
|
🚀 Deployed to https://deploy-preview-179--adapter-feishu.netlify.app |
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.
Forwarding a card to the bot lost the event without any reply or error message.
Message.deserializepassed the received content to the segment builders as arguments, and a received card hastitleandelements, whichMessageSegment.interactive()does not accept. TheTypeErrorwas raised insideBot.handle_event, before any matcher ran.The same crash applied to two more cases:
MessageSegment.system()does not accept their documenteddivider_textfield.Changes
Parsing
deserializeno longer expands the content into builder arguments._RECEIVED_SEGMENTSmaps each message type to its segment class, and the segment keeps the received content as it is. Types without a class, such asmerge_forwardandvote, stay generic as before.seg.datanow holds exactly what Feishu sent:None.data, so it is also sent if the segment is sent again.Received system messages are still
Systemsegments, so the check from #176 keeps working, including for dividers.Sending a received card
Received cards become
ReceivedInteractive, a subclass ofInteractive.seg.typeis stillinteractive.The documentation states that the received structure differs from the sent card JSON, which is the same situation as #176.
Message.serialize()now raisesValueErrorbefore any request is made, both alone and combined with other segments:Testing
test_received_message_reaches_matchersrunsBot.handle_eventwith a card and with an unknown field, because that is where the event was lost.pytestpasses on Python 3.11 and 3.15. Ruff passes, and Pyright reports nothing new inmessage.py.This was not tested with a card forwarded in a real Feishu client. The received structure comes from the documentation only.
This is independent of #178. Merging the two gives no conflicts and 140 passing tests, and a local fake Feishu confirmed that a card sent over the long connection reaches a matcher.