Skip to content

chore(telegram): remove dead image-document handling branch superseded by earlier merge #28676

@teknium1

Description

@teknium1

From post-merge audit of PR #28504 (#24815 salvage, route image documents through vision pipeline).

Bug

gateway/platforms/telegram.py has two redundant image-document handlers. The earlier one (bd0c54d17 fix: route Telegram image documents through photo handling, merged May 2) handles .png/.jpg/.jpeg/.webp/.gif at lines 4896-4922 and returns early. The later one (77c4675a5 fix(telegram): route image documents through vision pipeline, merged May 13 via #28504) adds another branch at lines 4947-4960 for the same extension set via SUPPORTED_IMAGE_DOCUMENT_TYPES.

Proof

_TELEGRAM_IMAGE_EXTENSIONS = {'.png', '.jpg', '.jpeg', '.webp', '.gif'} (line 89)
SUPPORTED_IMAGE_DOCUMENT_TYPES = {'.jpg', '.jpeg', '.png', '.webp', '.gif'} (gateway/platforms/base.py:851)

Both contain exactly the same extension set. The first branch at line 4896 fires on ext in _TELEGRAM_IMAGE_EXTENSIONS or doc_mime.startswith('image/') and returns. The second branch at line 4947 is unreachable because anything matching its condition (ext in SUPPORTED_IMAGE_DOCUMENT_TYPES) was already caught by the first branch.

Risk if removed

None. The second branch is dead.

Suggested cleanup

  • Delete lines 4947-4960 (the dead branch).
  • Remove the import of SUPPORTED_IMAGE_DOCUMENT_TYPES from telegram.py if not used elsewhere.
  • Keep the constant in base.py if it's used by other platforms.

Why this happened

bd0c54d17 merged from a different contributor's PR in early May. The salvaged PR #28504 was authored before that and never rebased — when I cherry-picked it, the original PR's downstream branch was added without recognizing the upstream branch already covered the same case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/gatewayGateway runner, session dispatch, deliveryplatform/telegramTelegram bot adaptertype/refactorCode restructuring, no behavior change

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions