From 2894966b6c7d9fbb202123cbcadb053ec153cb3b Mon Sep 17 00:00:00 2001 From: KT Date: Sat, 3 Jun 2023 11:14:15 +0800 Subject: [PATCH] fix(character): check type before access Check type before access relic's values in validator. --- mihomo/models/character.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mihomo/models/character.py b/mihomo/models/character.py index 72ea06c0..da77e0c8 100644 --- a/mihomo/models/character.py +++ b/mihomo/models/character.py @@ -142,8 +142,9 @@ class Character(BaseModel): @root_validator(pre=True) def dict_to_list(cls, data: dict[str, Any]): # The keys of the original dict is not necessary, so remove them here. - if data.get("relic") is not None: - data["relic"] = list(data["relic"].values()) + if isinstance(data, dict) and data.get("relic") is not None: + if isinstance(data["relic"], dict): + data["relic"] = list(data["relic"].values()) return data @property