From fffc2b2d9efb92e5c18e863f656445933c8e55be Mon Sep 17 00:00:00 2001 From: Alex Root Junior Date: Tue, 29 Aug 2023 01:43:29 +0300 Subject: [PATCH] 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. --- aiogram/types/base.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aiogram/types/base.py b/aiogram/types/base.py index 9c24c703..dae52156 100644 --- a/aiogram/types/base.py +++ b/aiogram/types/base.py @@ -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)}