From 236d96ef0615fa9a3ba5e4a1eabddb4ad6a198e4 Mon Sep 17 00:00:00 2001 From: CalamitousFelicitousness Date: Sun, 28 Jun 2026 02:39:06 +0100 Subject: [PATCH] fix(civitai): tolerate null creator username in search results Civitai returns a null username for deleted or anonymous creators. The field default only applies when the key is absent, so an explicit null failed str validation and rejected the entire CivitSearchResponse, dropping every model on that page. Coerce null or empty usernames to the default in a pre-validator so one bad creator no longer empties the whole search result. --- modules/civitai/models_civitai.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/civitai/models_civitai.py b/modules/civitai/models_civitai.py index 0d0ccd23a..4470efad3 100644 --- a/modules/civitai/models_civitai.py +++ b/modules/civitai/models_civitai.py @@ -73,6 +73,13 @@ class CivitCreator(BaseModel): username: str = "Unknown" image: str | None = None + @validator('username', pre=True) + def coerce_null_username(cls, v): # pylint: disable=no-self-argument + # Deleted/anonymous creators serialize username as null, which failed + # str validation and rejected the entire search response. Fall back to + # the default name instead of dropping the whole page. + return "Unknown" if v in (None, "") else v + class CivitModel(BaseModel): class Config: