Skip to content

Commit

Permalink
fix: don't iterate on None from gen_metadata key
Browse files Browse the repository at this point in the history
`dict.get(...)` returns the value of a key if it is set. The default parameter (the second parameter) only returns a default value **if the key does not exist**. Therefore, if the key `gen_metadata` is set in `kwargs`, and is set to `None`, then `kwargs.get("gen_metadata", [])` will return `None` and **not** an empty list (`[]`).
  • Loading branch information
tazlin committed Sep 27, 2024
1 parent bbd3f41 commit e74f58b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion horde/classes/stable/processing_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def log_aborted_generation(self):

def set_generation(self, generation, things_per_sec, **kwargs):
state = kwargs.get("state", "ok")
for metadata in kwargs.get("gen_metadata", []):
gen_metadata = kwargs.get("gen_metadata", []) or []
for metadata in gen_metadata:
if metadata.get("value") == "csam":
state = "csam"
else:
Expand Down

0 comments on commit e74f58b

Please sign in to comment.