Skip to content

Media Type Attribute Error in Message Manager #446

@Latand

Description

@Latand

The message manager encounters an AttributeError when trying to access the type attribute of the media field in NewMessage. This error occurs because the media field is sometimes being set as a string instead of the expected MediaAttachment type. The issue became apparent after the recent commit (5552ee2) that added voice message handling checks.

logs:

File "/usr/local/lib/python3.11/site-packages/aiogram_dialog/dialog.py", line 155, in callbackhandler
    await dialog_manager.show()
  File "/usr/local/lib/python3.11/site-packages/aiogram_dialog/manager/manager.py", line 372, in show
    sent_message = await self.message_manager.show_message(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiogram_dialog/manager/message_manager.py", line 198, in show_message
    if not self._can_edit(new_message, old_message):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiogram_dialog/manager/message_manager.py", line 154, in canedit
    if self.had_voice(old_message) or self.need_voice(new_message):
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiogram_dialog/manager/message_manager.py", line 126, in need_voice
    and new_message.media.type == ContentType.VOICE
        ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'type'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions