fix(channel): populate InboundMessage.mentioned_bot from mentions (fixes #134) - #151
Open
Xuxchloris wants to merge 1 commit into
Open
fix(channel): populate InboundMessage.mentioned_bot from mentions (fixes #134)#151Xuxchloris wants to merge 1 commit into
Xuxchloris wants to merge 1 commit into
Conversation
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.
Fixes #134
Problem
InboundMessage.mentioned_botis unconditionallyFalsefor every IM message, even when the bot is explicitly mentioned and the bot identity is resolved. Two compounding omissions inlark_oapi/channel/normalize/pipeline.py:extract_mentions(raw_mentions)never receivesbot_open_id, somentions.pycan never flag the bot self-mention.ext.mentioned_botis never forwarded to theInboundMessage(...)constructor — it falls back to itsFalsedefault.The internal
PolicyGateworks around this by re-computing the check inline (policy_gate.py), which confirms the field is known to be unreliable — but everyon("message")consumer readingmsg.mentioned_botalways getsFalse, causing "bot is @-mentioned but does not respond" bugs.The comment path already does this correctly:
_handle_comment_eventpassesbot_open_id=self._bot_open_idintonormalize_comment.Changes
pipeline.py:process()accepts an optionalbot_open_id; it is forwarded toextract_mentions, andext.mentioned_botis now passed toInboundMessage(...).channel.py:_handle_message_eventpassesbot_open_id=self._bot_open_id(same source the comment path uses).tests/test_pipeline.py: 3 new tests — bot inmentions[]→mentioned_bot=True(and the bot self-mention excluded from the publicmentionslist); nobot_open_id→False; bot not mentioned →False.Verification
python -m pytest lark_oapi/channel/tests— 660 passed; the single failure (test_upload_error_propagation.py::test_gather_buffer_missing_local_file_raises_upload_failed) is a pre-existing Windows-only path-escaping assertion that does not touch this code path (CI runs on Linux).