fix(graph): prevent SQL crash on empty LLM registry during migration

migrate_llm_models was generating invalid SQL 'NOT IN ()' when the
LLM registry is empty (e.g., fresh deployment before seeding). This
causes a fatal PostgreSQL error and prevents server startup.

Skip the migration with a warning if enum_values is empty.
This commit is contained in:
Bentlybro
2026-03-02 14:04:03 +00:00
parent 933887504b
commit 9bba427979

View File

@@ -1667,6 +1667,12 @@ async def migrate_llm_models(migrate_to: LlmModel):
from backend.data import llm_registry
enum_values = list(llm_registry.get_all_model_slugs_for_validation())
# Skip migration if registry is empty (fresh deployment before seeding)
if not enum_values:
logger.warning("LLM registry is empty, skipping model migration")
return
escaped_enum_values = repr(tuple(enum_values)) # hack but works
# Update each block