diff --git a/api/schemas/schemas.py b/api/schemas/schemas.py index f074f10bee..296d66021b 100644 --- a/api/schemas/schemas.py +++ b/api/schemas/schemas.py @@ -762,16 +762,15 @@ def transform_order(cls, values): @model_validator(mode="before") def add_missing_attributes(cls, values): # in case isEvent is wrong: - for f in values.get("filters"): + for f in values.get("filters") or []: if EventType.has_value(f["type"]) and not f.get("isEvent"): f["isEvent"] = True elif FilterType.has_value(f["type"]) and f.get("isEvent"): f["isEvent"] = False # in case the old search payload was passed - if len(values.get("events", [])) > 0: - for v in values["events"]: - v["isEvent"] = True + for v in values.get("events") or []: + v["isEvent"] = True return values