Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media Type Attribute Error in Message Manager #446

Open
Latand opened this issue Dec 2, 2024 · 1 comment
Open

Media Type Attribute Error in Message Manager #446

Latand opened this issue Dec 2, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Latand
Copy link
Contributor

Latand commented Dec 2, 2024

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'
@Tishka17
Copy link
Owner

Tishka17 commented Dec 2, 2024

it is very strange because

media: Optional[MediaAttachment] = None

https://github.com/Tishka17/aiogram_dialog/blob/develop/src/aiogram_dialog/api/entities/new_message.py

@Tishka17 Tishka17 added the bug Something isn't working label Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants