{"record":{"id":"c4ddccfab9bf711c","repo":"zylon-ai/private-gpt","slug":"default-model-self-default-model-id-not-found","errorCode":null,"errorMessage":"Default model '{self._default_model_id}' not found in registered models","messagePattern":"Default model '(.+?)' not found in registered models","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"private_gpt/components/llm/llm_component.py","lineNumber":117,"sourceCode":"                        f\"Default LLM model '{model_id}' could not be initialized: {e}\"\n                    ) from e\n                logger.warning(\n                    \"Skipping unavailable LLM model '%s': %s\",\n                    model_id,\n                    e,\n                )\n\n        if not self._default_model_id and registered_model_ids:\n            self._default_model_id = next(iter(self.llm_models))\n            logger.warning(\n                \"No default LLM model configured. Auto-selecting: '%s'\",\n                self._default_model_id,\n            )\n\n        if self._default_model_id:\n            default_instance = self.registry.get(self._default_model_id)\n            if not default_instance:\n                raise ValueError(\n                    f\"Default model '{self._default_model_id}' not found in registered models\"\n                )\n\n            if not self.registry.get(LLMRegistry.default()):\n                self.registry.register(LLMRegistry.default(), default_instance)\n\n            logger.info(\"Set default model to '%s'\", self._default_model_id)\n\n    def get_llm(self, model_id: str | None = None) -> LLM:\n        target_model = model_id or self._default_model_id\n\n        if not target_model:\n            raise ValueError(\"No model specified and no models are configured\")\n\n        llm_instance = self.registry.get(target_model)\n        if not llm_instance:\n            available = self.registry.get_all_aliases()\n            raise ValueError(","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/private_gpt/components/llm/llm_component.py#L99-L135","documentation":"ValueError from LLMComponent setup: after registering models, the configured default model id is not present in the registry. This happens when the default id was never registered — its config was skipped earlier (e.g. init failure for a non-default path, empty model list, or a settings key mismatch between default_model_id and llm_models keys).","triggerScenarios":"settings specify default_model_id: X but no entry X exists under llm.models (name mismatch, indentation error in YAML), or X failed to register while another model was default-eligible.","commonSituations":"YAML indentation moving the default under the wrong key; renaming a model without updating default_model_id; model entries disabled/removed while the default still points at the old name.","solutions":["Compare default_model_id against the exact keys of llm.models in settings (watch indentation, casing, quotes).","Rename the default to an existing, successfully registered model id.","If the model exists but failed to register, fix its init error first (see the skip warnings in logs)."],"exampleFix":"# before\nllm:\n  default_model: gpt4-old\n  models:\n    gpt4-old: {...}   # typo/renamed\n\n# after\nllm:\n  default_model: gpt-4o\n  models:\n    gpt-4o: {...}","handlingStrategy":"validation","validationCode":"def default_model_is_registered(settings) -> bool:\n    default = settings.llm.default_model\n    return default is not None and default in (settings.llm.models or {})","typeGuard":null,"tryCatchPattern":"try:\n    component = LLMComponent()\nexcept ValueError as e:\n    if 'not found in registered models' in str(e):\n        # fix default_model vs llm.models keys, then restart\n        raise ConfigError(str(e)) from e\n    raise","preventionTips":["Add a settings test asserting default_model is a key of llm.models.","Use YAML schema validation (pydantic settings) so key mismatches fail at parse time.","After renaming models, grep settings for stale references to old ids."],"tags":["configuration","startup","llm","yaml"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}