{"record":{"id":"aa69bc13832a7c49","repo":"zylon-ai/private-gpt","slug":"unknown-default-model-type-model-requested-def","errorCode":null,"errorMessage":"Unknown default {model_type} model '{requested_default}'. Available discovered models: {available}","messagePattern":"Unknown default (.+?) model '(.+?)'\\. Available discovered models: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/auto_discover_models.py","lineNumber":82,"sourceCode":"        data.pop(\"sampling_params\", None)\n        data.pop(\"reasoning_sampling_params\", None)\n    tags = data.get(\"tags\")\n    if isinstance(tags, list):\n        data[\"tags\"] = sorted(tags)\n    return data\n\n\ndef _resolve_default_model(\n    requested_default: str | None,\n    configured_default: str,\n    discovered_models: list[LLMModelConfig] | list[EmbeddingModelConfig],\n    model_type: str,\n) -> str:\n    discovered_names = {model.name for model in discovered_models}\n    if requested_default:\n        if requested_default not in discovered_names:\n            available = \", \".join(sorted(discovered_names)) or \"none\"\n            raise ValueError(\n                f\"Unknown default {model_type} model '{requested_default}'. \"\n                f\"Available discovered models: {available}\"\n            )\n        return requested_default\n\n    if configured_default and configured_default in discovered_names:\n        return configured_default\n    if discovered_models:\n        return discovered_models[0].name\n    return \"\"\n\n\ndef _find_model(\n    models: list[EmbeddingModelConfig],\n    name: str,\n) -> EmbeddingModelConfig | None:\n    return next((model for model in models if model.name == name), None)\n","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/scripts/auto_discover_models.py#L64-L100","documentation":"Raised by scripts/auto_discover_models.py when the requested default model name (from the CLI or configured default) does not match any model discovered from PGPT_MODELS_* environment variables. After discovery builds the set of model names, _resolve_default_model validates the explicitly requested default against that set and refuses to guess, listing all discovered names (or 'none' if discovery found nothing).","triggerScenarios":"Running auto_discover_models.py --default-llm gpt-4o while only PGPT_MODELS_LLAMA3_* variables are set; the requested name differing in case or whitespace from the discovered name (model IDs are lowercased during discovery); discovery finding zero models because no PGPT_MODELS_ vars with at least 3 underscores are set, making every default invalid.","commonSituations":"Renaming a model's env vars without updating the default flag; drift between the discovery environment (CI job with injected secrets) and the local shell where discovery is empty; passing a display name ('GPT-4o') instead of the env-derived ID ('gpt4').","solutions":["Run the script once without --default-llm/--default-embedding and read the 'Available discovered models' list in the error/output, then request one of those exact names","Set the PGPT_MODELS_<ID>_* variables so the desired model is actually discovered before requesting it as default","Match the exact lowercased model ID derived from the env var name (PGPT_MODELS_GPT4_API_KEY -> 'gpt4')","If you intended the configured YAML default, omit the CLI default flag - it is used only when present"],"exampleFix":"# before\nexport PGPT_MODELS_LLAMA3_API_KEY=k\npython scripts/auto_discover_models.py --default-llm gpt-4o\n\n# after\npython scripts/auto_discover_models.py --default-llm llama3","handlingStrategy":"validation","validationCode":"import os\n\ndef discovered_model_names() -> set[str]:\n    names = set()\n    for key in os.environ:\n        if key.startswith(\"PGPT_MODELS_\") and key.count(\"_\") >= 3:\n            _, _, mid, _ = key.split(\"_\", 3)\n            names.add(mid.lower())\n    return names\n\nrequested = \"gpt-4o\".strip().lower()\nassert requested in discovered_model_names(), f\"{requested} not discovered\"","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Derive the default model name from the same env var stem you set (PGPT_MODELS_X_... -> default 'x')","Run discovery once without a --default flag and read the available list before pinning a default","Remember model IDs are lowercased during discovery; request the lowercase form","Ensure the PGPT_MODELS_* variables are present in the environment that executes the script"],"tags":["models","discovery","environment-variables","scripts"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}