Ensure base type validation can handle non-dictionary values

The update introduces a condition to verify whether the values being validated are a dictionary before attempting to handle UNSET_TYPE in the aiogram base type. This adjustment helps to prevent potential errors or incorrect validation when non-dictionary values are faced.
This commit is contained in:
Alex Root Junior 2023-08-29 01:43:29 +03:00
parent e1be9dd668
commit fffc2b2d9e
No known key found for this signature in database
GPG key ID: 074C1D455EBEA4AC

View file

@ -28,6 +28,8 @@ class TelegramObject(BotContextController, BaseModel):
but UNSET might be passed to a model initialization from `Bot.method_name`,
so we must take care of it and remove it before fields validation.
"""
if not isinstance(values, dict):
return values
return {k: v for k, v in values.items() if not isinstance(v, UNSET_TYPE)}