fix: replace substring caption check with exact line-by-line match (all platforms)#5939
Merged
Conversation
…e match Captions in photo bursts and media group albums were silently dropped when a shorter caption happened to be a substring of an existing one (e.g. "Meeting" lost inside "Meeting agenda"). Extract a shared _merge_caption static helper that splits on "\n\n" and uses exact match with whitespace normalisation, then use it in both _enqueue_photo_event and _queue_media_group_event. Adds 13 unit tests covering the fixed bug scenarios. Cherry-picked from PR #2671 by Dilee.
Move _merge_caption helper from TelegramAdapter to BasePlatformAdapter so all adapters inherit it. Fix the same substring-containment bug in: - gateway/platforms/base.py (photo burst merging) - gateway/run.py (priority photo follow-up merging) - gateway/platforms/feishu.py (media batch merging) The original fix only covered telegram.py. The same bug existed in base.py and run.py (pure substring check) and feishu.py (list membership without whitespace normalization).
15 tasks
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.
Summary
Salvages PR #2671 by Dilee and extends the fix to all platforms.
Bug: Caption merging in photo bursts and media group albums used
event.text not in existing.text(substring containment). This silently dropped captions when a shorter one happened to be a substring of a longer one — e.g., "Meeting" was dropped when "Meeting agenda" already existed because"Meeting" in "Meeting agenda"evaluates to True.Fix: Extract a
_merge_captionstatic helper onBasePlatformAdapterthat splits on\n\nboundaries and uses exact match with whitespace normalization. All 5 buggy sites now use this single helper:gateway/platforms/telegram.py:2111gateway/platforms/telegram.py:2303gateway/platforms/base.py:1148gateway/run.py:1985gateway/platforms/feishu.py:2075Commits
Test results
Closes #2671. Credit to @dilekakbas for the original fix and tests.