Skip to content

Commit 5996e31

Browse files
feat(mm): better errors when invalid model config found in db
1 parent c88fee6 commit 5996e31

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

invokeai/app/services/model_records/model_records_sql.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,19 @@ def search_by_attr(
292292
for row in result:
293293
try:
294294
model_config = ModelConfigFactory.make_config(json.loads(row[0]), timestamp=row[1])
295-
except pydantic.ValidationError:
295+
except pydantic.ValidationError as e:
296296
# We catch this error so that the app can still run if there are invalid model configs in the database.
297297
# One reason that an invalid model config might be in the database is if someone had to rollback from a
298298
# newer version of the app that added a new model type.
299299
row_data = f"{row[0][:64]}..." if len(row[0]) > 64 else row[0]
300+
try:
301+
name = json.loads(row[0]).get("name", "<unknown>")
302+
except Exception:
303+
name = "<unknown>"
300304
self._logger.warning(
301-
f"Found an invalid model config in the database. Ignoring this model. ({row_data})"
305+
f"Skipping invalid model config in the database with name {name}. Ignoring this model. ({row_data})"
302306
)
307+
self._logger.warning(f"Validation error: {e}")
303308
else:
304309
results.append(model_config)
305310

0 commit comments

Comments
 (0)