infiniflow/ragflow · error · LookupError
Model {model_name} not found.
Error message
Model {model_name} not found. What it means
LookupError raised by get_model_type_by_name as the final gate: provider and instance both resolved, but TenantModelService.get_by_provider_id_and_instance_id_and_model_name found no tenant_model row for the pure model name. Unlike the id-resolution variant (line 399) this lookup is not filtered by model_type, so failure means the model name simply isn't registered under that provider+instance at all.
Source
Thrown at api/db/joint_services/tenant_model_service.py:504
def resolve_model_type(tenant_id: str, model_ref: str):
try:
return get_model_type_by_id(model_ref)
except LookupError:
return get_model_type_by_name(tenant_id, model_ref)
def get_model_type_by_name(tenant_id: str, model_name: str):
pure_model_name, instance_name, provider_name = split_model_name(model_name)
provider_obj = TenantModelProviderService.get_by_tenant_id_and_provider_name(tenant_id, provider_name)
if not provider_obj:
raise LookupError(f"Provider {provider_name} not found for model {model_name}.")
instance_obj = TenantModelInstanceService.get_by_provider_id_and_instance_name(provider_obj.id, instance_name)
if not instance_obj:
raise LookupError(f"Instance {instance_name} not found for model {model_name}.")
model_obj = TenantModelService.get_by_provider_id_and_instance_id_and_model_name(provider_obj.id, instance_obj.id, pure_model_name)
if not model_obj:
raise LookupError(f"Model {model_name} not found.")
return get_model_type_human(model_obj.model_type)
def delete_models_by_instance_ids(instance_ids: list[str]):
return TenantModelService.delete_by_instance_ids(instance_ids)
def delete_instances_by_provider_ids(provider_ids: list[str]):
return TenantModelInstanceService.delete_by_provider_ids(provider_ids)
def ensure_opendataloader_from_env(tenant_id: str) -> str | None:
return _ensure_ocr_provider_from_env(
tenant_id,
"OpenDataLoader",
"opendataloader-from-env",
_collect_env_config(OPENDATALOADER_ENV_KEYS, OPENDATALOADER_DEFAULT_CONFIG),
)View on GitHub (pinned to 554fb1133a)
Solutions
- List the provider's models (tenant_model by provider_id+instance_id) and correct the name to the stored value exactly.
- Re-add the model under the provider if it was removed.
- Use the tenant_model id with resolve_model_type to bypass name matching.
Defensive patterns
Strategy: try-catch
Validate before calling
rows = TenantModelService.get_by_provider_id_and_instance_id_and_model_name(provider.id, instance.id, pure_name)
if not rows:
raise ValueError(f"'{pure_name}' is not registered under {provider_name}; check exact spelling") Try / catch
try:
t = get_model_type_by_name(tenant_id, model_name)
except LookupError as e:
if str(e) == f"Model {model_name} not found.":
raise ValueError("Model name not registered under this provider") Prevention
- Copy model names from the provider's model list rather than typing them.
- Trim whitespace and preserve case when storing custom model names.
- This lookup is NOT type-filtered — failure means the name itself is unknown.
When it happens
Trigger: Calling get_model_type_by_name with 'typo-model@Provider'; a model removed from the provider's list; names differing in case/whitespace from the registered tenant_model name.
Common situations: Custom model names retyped by hand; provider model list refreshed and the row dropped; names with trailing spaces from form input.
Related errors
- Model {model_name} not found for type {model_type_val}.
- TenantModel id={model_id} not found.
- TenantModel id={model_id} is disabled.
- TenantModel id={model_id} cannot be used as {model_type_val}
- Provider name is required to resolve model id for {model_nam
AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15).
Data as JSON: /api/errors/98421d324f3aae4a.
Report an issue: GitHub.