Repository navigation
🐛 reject sending received system messages - #176
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #176 +/- ##
==========================================
+ Coverage 83.80% 83.82% +0.01%
==========================================
Files 15 15
Lines 1717 1719 +2
==========================================
+ Hits 1439 1441 +2
Misses 278 278
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-176--adapter-feishu.netlify.app |
MessageSegment.system and received system messages use the received fields, which do not match the documented send format. Raise ValueError before any request and point to MessageSegment.system_divider.
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.
Stacked on #174, which is the base branch of this PR, because the error points to
MessageSegment.system_divider().MessageSegment.system()and received system messages use the received fields (template,from_user,to_chatters). Feishu's send format usestype,params, andoptions, sosystempassed themsg_typeallowlist from #173 while its content did not match the documentation.Changes
Message.serialize()now raisesValueErrorfor these segments before any request is made, both alone and combined with other segments:The check uses the
Systemclass, so these are not affected:MessageSegment.system_divider().MessageSegment("system", ...)with content in the documented format.Message.deserialize()andstr()for received system messages.MessageSegment.system()stays available becauseMessage.deserialize()uses it, and its docstring now says it cannot be used for sending.Behaviour change
Sending a received system message again, or sending a segment built with
MessageSegment.system(), now raisesValueError.Verification
systemcase fromtest_serialize_rejects_segment_not_supported_in_post, because that test required the behaviour changed here.ruffand the pre-commit hooks pass.send()with a stub bot and confirmed that no request is made when it raises.Not tested against the live Feishu API.