lfnovo/open-notebook · critical · RuntimeError

Failed to load default models configuration

Error message

Failed to load default models configuration

What it means

Raised by ModelManager.get_defaults() when DefaultModels.get_instance() returns None — i.e. the singleton default-models row cannot be loaded from SurrealDB. Every model lookup (embedding, STT, TTS, default LLM, content processing) funnels through get_defaults(), so this error blocks nearly all AI features. It usually means the database is unreachable, migrations have not created the DefaultModels record, or the record was deleted.

Solutions

  1. Verify SurrealDB is running (make database) and restart the API so startup migrations/seed run
  2. Check OPEN_NOTEBOOK_DB* env vars point to the intended namespace/database
  3. Query SurrealDB directly (SELECT * FROM default_models) to confirm the singleton exists; if missing, restart API to re-seed or recreate via the Settings API
  4. As a last resort, clear and re-run migrations on a dev database
Defensive patterns

Strategy: try-catch

Validate before calling

from open_notebook.database.repository import repo_query
rows = await repo_query("SELECT * FROM default_models LIMIT 1")
if not rows:
    # trigger setup / seeding before any AI call
    ...

Try / catch

try:
    model = await model_manager.get_default_model('language')
except RuntimeError as e:
    if 'default models configuration' in str(e):
        raise HTTPException(503, 'Models not configured — run setup')
    raise

Prevention

When it happens

Trigger: Calling any of get_speech_to_text, get_text_to_speech, get_embedding_model, get_default_model, or content_process before the DefaultModels row exists; running against a fresh/empty SurrealDB; pointing OPEN_NOTEBOOK_DB at the wrong namespace/database; API started before SurrealDB (schema migrations that seed defaults never ran).

Common situations: Fresh install where startup migrations didn't run (API started before database), wrong SurrealDB connection env vars, a migrated schema missing the seeded DefaultModels singleton, or accidentally deleting the settings record via the UI/API.

Related errors


AI-assisted analysis of lfnovo/open-notebook@a7de90d38a (2026-08-27). Data as JSON: /api/errors/479877b82b6be474. Report an issue: GitHub.

Appendix: source

Thrown at open_notebook/ai/models.py:291

            return AIFactory.create_speech_to_text(
                model_name=model.name,
                provider=provider,
                config=config,
            )
        elif model.type == "text_to_speech":
            return AIFactory.create_text_to_speech(
                model_name=model.name,
                provider=provider,
                config=config,
            )
        else:
            raise ConfigurationError(f"Invalid model type: {model.type}")

    async def get_defaults(self) -> DefaultModels:
        """Get the default models configuration from database"""
        defaults = await DefaultModels.get_instance()
        if not defaults:
            raise RuntimeError("Failed to load default models configuration")
        return defaults

    async def get_speech_to_text(self, **kwargs) -> Optional[SpeechToTextModel]:
        """Get the default speech-to-text model"""
        defaults = await self.get_defaults()
        model_id = defaults.default_speech_to_text_model
        if not model_id:
            return None
        model = await self.get_model(model_id, **kwargs)
        assert model is None or isinstance(model, SpeechToTextModel), (
            f"Expected SpeechToTextModel but got {type(model)}"
        )
        return model

    async def get_text_to_speech(self, **kwargs) -> Optional[TextToSpeechModel]:
        """Get the default text-to-speech model"""
        defaults = await self.get_defaults()
        model_id = defaults.default_text_to_speech_model

View on GitHub (pinned to a7de90d38a)