Skip to content

Конфликт сериализации Pydantic V2 и ссылок в кнопках pybotx #542

Description

@Shamilen

Использую pybotx v0.76.2
Модель BotXAPIButton требует обязательное поле command: str.
А в классе Button
command: Missing[str] = Undefined
Это создает проблему при использовании кнопок-ссылок link:

  1. Если не передать command: Pydantic V2 выдает предупреждение PydanticSerializationUnexpectedValue, так как вместо строки получает Undefined.
/usr/local/lib/python3.14/site-packages/pydantic/main.py:475: UserWarning: Pydantic serializer warnings:
  PydanticSerializationUnexpectedValue(Expected `str` - serialized value may not be as expected [field_name='command', input_value=Undefined, input_type=_UndefinedType])
  1. Если передать command="": Предупреждение исчезает, но ломается ссылка в клиенте eXpress (игнорирует URL, если поле command не пустое).

Проблема не критичная, Warn от Pydantic падает один раз при первом вызове.

Пример из Readme :
https://github.com/ExpressApp/pybotx/blob/master/README.md?plain=1#L428

Пример моей реализации:

bubbles.add_button(
    label=f"🧑‍💻 В работе у {user_name}",
    #command="",
    link=f"https://xlnk.ms/open/profile/{link_user}",
    background_color="#006400",
    new_row=True,
)

Activity

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions