{"record":{"id":"5cb5878ec6d2d53f","repo":"HKUDS/DeepTutor","slug":"no-active-image-generation-model-is-configured-se","errorCode":null,"errorMessage":"No active image-generation model is configured. Set it in Settings > Media Generation > Image Generation.","messagePattern":"No active image-generation model is configured\\. Set it in Settings > Media Generation > Image Generation\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"deeptutor/services/config/provider_runtime.py","lineNumber":1085,"sourceCode":"        base_url=api_base,\n        api_version=_as_str((profile or {}).get(\"api_version\")) or None,\n        extra_headers=_to_headers((profile or {}).get(\"extra_headers\")),\n        language=_as_str((model or {}).get(\"language\")) or None,\n    )\n\n\ndef resolve_imagegen_runtime_config(\n    catalog: dict[str, Any] | None = None,\n    *,\n    service: ModelCatalogService | None = None,\n) -> ImagegenConfig:\n    \"\"\"Resolve the active text-to-image config from the model catalog.\"\"\"\n    catalog_service = service or get_model_catalog_service()\n    loaded = _load_catalog(catalog)\n    profile, model = _active_profile_and_model(loaded, catalog_service, \"imagegen\")\n    resolved_model = _as_str((model or {}).get(\"model\"))\n    if not resolved_model:\n        raise ValueError(\n            \"No active image-generation model is configured. \"\n            \"Set it in Settings > Media Generation > Image Generation.\"\n        )\n\n    provider = _canonical_generation_provider(\n        _as_str((profile or {}).get(\"binding\")), IMAGEGEN_PROVIDERS\n    )\n    spec = IMAGEGEN_PROVIDERS[provider]\n    api_base = _as_str((profile or {}).get(\"base_url\")) or spec.default_api_base\n    api_key = _as_str((profile or {}).get(\"api_key\"))\n    if not api_key and spec.is_local:\n        api_key = \"sk-no-key-required\"\n\n    return ImagegenConfig(\n        model=resolved_model,\n        provider_name=provider,\n        adapter=spec.adapter,\n        auth_style=spec.auth_style,","sourceCodeStart":1067,"sourceCodeEnd":1103,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/services/config/provider_runtime.py#L1067-L1103","documentation":"Raised by resolve_imagegen_runtime_config when the active profile's model entry in the model catalog has no 'model' field (empty/missing model id) for the 'imagegen' category. The resolver refuses to build a generation config without a concrete model name. It is a configuration error, thrown before any provider call.","triggerScenarios":"Calling generate_image or the provider test hook (_test_imagegen) when Settings > Media Generation > Image Generation has no active model selected, or the catalog JSON has an imagegen profile whose model object lacks a 'model' key.","commonSituations":"Fresh install where media generation was never configured; catalog reset/migration wiped the model field; UI allows saving an empty model selection; tests asserting the error path (test_resolve_imagegen_config_raises_without_model).","solutions":["Set an active image-generation model in Settings > Media Generation > Image Generation","Edit the model catalog JSON so the active imagegen profile's model object contains a non-empty 'model' string","Guard programmatic callers with a pre-check and surface a setup prompt instead of crashing"],"exampleFix":"// before\ncfg = resolve_imagegen_runtime_config()  # ValueError\n// after\ntry:\n    cfg = resolve_imagegen_runtime_config()\nexcept ValueError as e:\n    print(\"configure image model:\", e)\n    raise SystemExit(2)","handlingStrategy":"validation","validationCode":"def imagegen_configured() -> bool:\n    try:\n        resolve_imagegen_runtime_config()\n        return True\n    except ValueError:\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    cfg = resolve_imagegen_runtime_config()\nexcept ValueError as e:\n    if \"image-generation model\" in str(e):\n        prompt_user_to_configure(\"imagegen\")\n    raise","preventionTips":["Gate image-generation UI/actions behind a config pre-check","Validate the catalog after migrations: active imagegen profile must have a non-empty model string"],"tags":["config","image-generation","model-catalog"],"backgroundTag":"missing-model-configuration","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}