Skip to content

fix: replace substring caption check with exact line-by-line match (all platforms)#5939

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-c7eda492
Apr 7, 2026
Merged

fix: replace substring caption check with exact line-by-line match (all platforms)#5939
teknium1 merged 2 commits into
mainfrom
hermes/hermes-c7eda492

Conversation

@teknium1

@teknium1 teknium1 commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

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_caption static helper on BasePlatformAdapter that splits on \n\n boundaries and uses exact match with whitespace normalization. All 5 buggy sites now use this single helper:

File Old Pattern Status
gateway/platforms/telegram.py:2111 Pure substring check Fixed (PR #2671)
gateway/platforms/telegram.py:2303 List membership, no strip() Fixed (PR #2671)
gateway/platforms/base.py:1148 Pure substring check Fixed (follow-up)
gateway/run.py:1985 Pure substring check Fixed (follow-up)
gateway/platforms/feishu.py:2075 List membership, no strip() Fixed (follow-up)

Commits

  1. Dilee's cherry-picked commit — telegram.py fix + 13 unit tests (preserves original authorship)
  2. Follow-up — moves helper to BasePlatformAdapter, fixes remaining 3 sites

Test results

  • 13 caption merge tests: all pass
  • Gateway suite: 2142 passed (10 pre-existing failures in unrelated areas)

Closes #2671. Credit to @dilekakbas for the original fix and tests.

dlkakbs and others added 2 commits April 7, 2026 14:01
…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).
@teknium1 teknium1 merged commit 125e5ef into main Apr 7, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants