Skip to content

fix(telegram): caption-less media messages crash with ChatMessage ValidationError (content min_length=1) #10483

Closed

Description

@mrveiss

Summary

Same defect class as #10481 but on the Telegram channel (#9006). api/telegram_bot.py:191 builds:

chat_message = ChatMessage(content=unified_message.message, ...)

unified_message.message comes from telegram_adapter.py:56:

text = message.get("text", "") or message.get("caption", "")

For a caption-less photo / document / voice / video / audio message, text == "". ChatMessage.content is Field(..., min_length=1, ...) (api/schemas_chat.py:463), so constructing it raises pydantic ValidationError.

Impact

Every caption-less media message received via the Telegram bot raises ValidationError in handle_telegram_update, so the message is not routed to chat and no reply is sent — the common case (sending a photo/voice with no caption) is broken.

Fix (mirror #10481)

When unified_message.message is empty but metadata.get("has_file") is set, synthesize a placeholder content naming the attachment, e.g. f"[{file_type} attachment]", before constructing ChatMessage. The Telegram adapter already records file_type/mime_type in metadata (telegram_adapter.py:48-53).

Found while fixing the equivalent WhatsApp bug (#10481) during verification of umbrella #9928.

Activity

  1. mrveiss commented on Jun 23, 2026

    @mrveiss
    OwnerAuthor

    Fixed in PR #10486 (merged to Dev_new_gui): caption-less Telegram media now gets a [<file_type> attachment] placeholder so ChatMessage construction no longer raises ValidationError. Regression test added (api/telegram_bot_test.py, 10 passed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions