Skip to content

Commit

Permalink
fix(character): check type before access
Browse files Browse the repository at this point in the history
Check type before access relic's values in validator.
  • Loading branch information
KT-Yeh committed Jun 3, 2023
1 parent 2137332 commit 2894966
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mihomo/models/character.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2894966

Please sign in to comment.