mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-04-23 03:00:31 -04:00
feat(mm): better errors when invalid model config found in db
This commit is contained in:
@@ -292,14 +292,19 @@ class ModelRecordServiceSQL(ModelRecordServiceBase):
|
||||
for row in result:
|
||||
try:
|
||||
model_config = ModelConfigFactory.make_config(json.loads(row[0]), timestamp=row[1])
|
||||
except pydantic.ValidationError:
|
||||
except pydantic.ValidationError as e:
|
||||
# We catch this error so that the app can still run if there are invalid model configs in the database.
|
||||
# One reason that an invalid model config might be in the database is if someone had to rollback from a
|
||||
# newer version of the app that added a new model type.
|
||||
row_data = f"{row[0][:64]}..." if len(row[0]) > 64 else row[0]
|
||||
try:
|
||||
name = json.loads(row[0]).get("name", "<unknown>")
|
||||
except Exception:
|
||||
name = "<unknown>"
|
||||
self._logger.warning(
|
||||
f"Found an invalid model config in the database. Ignoring this model. ({row_data})"
|
||||
f"Skipping invalid model config in the database with name {name}. Ignoring this model. ({row_data})"
|
||||
)
|
||||
self._logger.warning(f"Validation error: {e}")
|
||||
else:
|
||||
results.append(model_config)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user