{"record":{"id":"ffdfaef70f68788e","repo":"infiniflow/ragflow","slug":"model-model-name-not-found-for-type-model-type","errorCode":null,"errorMessage":"Model {model_name} not found for type {model_type_val}.","messagePattern":"Model (.+?) not found for type (.+?)\\.","errorType":"exception","errorClass":"LookupError","httpStatus":null,"severity":"error","filePath":"api/db/joint_services/tenant_model_service.py","lineNumber":399,"sourceCode":"    # Builtin TEI embedding — no tenant_model row exists\n    compose_profiles = os.getenv(\"COMPOSE_PROFILES\", \"\")\n    is_tei_builtin_embedding = (\n        model_type_val == LLMType.EMBEDDING.value and \"tei-\" in compose_profiles and pure_model_name == os.getenv(\"TEI_MODEL\", \"\") and (provider_name == \"Builtin\" or not provider_name)\n    )\n    if is_tei_builtin_embedding:\n        return None\n\n    if not provider_name:\n        raise LookupError(f\"Provider name is required to resolve model id for {model_name}.\")\n\n    provider_obj = TenantModelProviderService.get_by_tenant_id_and_provider_name(tenant_id, provider_name)\n    if not provider_obj:\n        raise LookupError(f\"Provider {provider_name} not found for model {model_name}.\")\n\n    instance_obj = _resolve_instance_for_model(provider_obj, instance_name, model_name)\n    model_obj = TenantModelService.get_by_provider_id_and_instance_id_and_model_type_and_model_name(provider_obj.id, instance_obj.id, model_type_val, pure_model_name)\n    if not model_obj:\n        raise LookupError(f\"Model {model_name} not found for type {model_type_val}.\")\n    return model_obj.id\n\n\n# Mapping from model-name field → (LLMType, tenant_model id field)\n_MODEL_NAME_TO_ID_FIELD_MAP: dict[str, tuple[str, str]] = {\n    \"llm_id\": (LLMType.CHAT, \"tenant_llm_id\"),\n    \"embd_id\": (LLMType.EMBEDDING, \"tenant_embd_id\"),\n    \"rerank_id\": (LLMType.RERANK, \"tenant_rerank_id\"),\n    \"asr_id\": (LLMType.ASR, \"tenant_asr_id\"),\n    \"img2txt_id\": (LLMType.VISION, \"tenant_img2txt_id\"),\n    \"tts_id\": (LLMType.TTS, \"tenant_tts_id\"),\n}\n\n\ndef ensure_tenant_model_ids_for_params(tenant_id: str, params: dict) -> dict:\n    \"\"\"For each model-name field present in *params*, resolve the corresponding\n    tenant_model id if the id field is not already present.\n","sourceCodeStart":381,"sourceCodeEnd":417,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/api/db/joint_services/tenant_model_service.py#L381-L417","documentation":"LookupError raised in name-based id resolution when the provider and instance resolved fine but TenantModelService.get_by_provider_id_and_instance_id_and_model_type_and_model_name found no tenant_model row for the pure model name under that provider+instance with that model_type. All three keys (provider, instance, model_type, model name) must match a registered row.","triggerScenarios":"Resolving 'some-model@Provider' where 'some-model' was never added under that provider for this tenant; the model was added under a different model_type than requested (embedding vs chat); the model name has a typo or the provider's model list changed and the row was removed.","commonSituations":"Custom/self-hosted models added with a slightly different name ('qwen2.5-7b' vs 'Qwen2.5-7B'); requesting a type the row does not carry so the type-filtered query returns empty; stale names in old DSL after model re-registration.","solutions":["Open Model Providers, expand the provider, and confirm the model is listed with the exact name; re-add it if missing.","Check the requested model_type matches how the model was added (e.g. an embedding-only entry will not resolve for CHAT).","Re-copy the full 'model@provider' string from the UI selector into your config.","Query tenant_model by provider_id and instance_id to see the exact stored names."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"provider = TenantModelProviderService.get_by_tenant_id_and_provider_name(tenant_id, provider_name)\ninstance = _resolve_instance_for_model(provider, instance_name, model_name)\nif not TenantModelService.get_by_provider_id_and_instance_id_and_model_type_and_model_name(\n        provider.id, instance.id, model_type.value, pure_name):\n    raise ValueError(f\"Model '{pure_name}' not registered under {provider_name}\")","typeGuard":null,"tryCatchPattern":"try:\n    model_id = get_model_id_from_name(tenant_id, model_type, model_name)\nexcept LookupError as e:\n    if \"not found for type\" in str(e):\n        # permanent: name/registration mismatch, no retry\n        raise","preventionTips":["Register custom models with stable, exact names before referencing them in config.","When re-adding a model, keep the name identical to avoid breaking stored references.","Validate the full provider->instance->model chain when onboarding a new model."],"tags":["model-name","tenant-model","provider","ragflow"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}