Skip to content

mashumaro.exceptions.InvalidFieldValue: Field "chats" of type List[GetChatByIdResponse] in GetChatsResponse has invalid value #7

@alliaswolf

Description

@alliaswolf

Обнаружена ошибка при выполнении команды bot.get_chats()
mashumaro.exceptions.InvalidFieldValue: Field "chats" of type List[GetChatByIdResponse] in GetChatsResponse has invalid value

Это связано с ключом "content", внутри которого словарь, у которого есть ключ "title".

{
    'chatId': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    'title': 'АБВГД',
    'chatType': 2,
    'avatarUrl': None,
    'lastMessage': {
        'messageId': 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
        'timestamp': 1774858929884,
        'author': {
            'id': 'ivanov.ivan',
            'type': 0
        },
        'type': 21,
        'content': {
            'title': 'АБВГД'
        }
    },
    'unreadMessages': 0
}

Такая ошибка возникла при изменении названии канала. Сообщение системное, и оно является последним в канале.

Иванов Иван изменил название чата на "АБВГД"

Видимо, нужно исправить аннотацию типов для "content"

class LastMessage(DataClassDictMixin):
    message_id: str = field(metadata={"alias": "messageId"})
    timestamp: int
    author: EnvelopeAuthor
    type: MessageType
    content: Union[TextContent, AttachmentContent, SurveyContent, ParticipantRoleContent, RemoveParticipant, ForwardMessage]

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions