infiniflow/ragflow · error · LookupError
TenantModel id={model_id} cannot be used as {model_type_val}
Error message
TenantModel id={model_id} cannot be used as {model_type_val} model. What it means
LookupError raised by get_model_config_by_id when tenant_model.status equals ActiveStatusEnum.UNSUPPORTED. The row exists and is not disabled, but its status marks the model as unsupported (e.g. the provider type is not usable for this deployment). The message reuses the 'cannot be used as {model_type_val} model' wording also used for the model_type bitmask failure, so distinguish this raise (status-based, line 334) from the bitmask raise (line 336).
Source
Thrown at api/db/joint_services/tenant_model_service.py:334
if api_key_payload is not None:
model_config["api_key_payload"] = api_key_payload
return model_config
else:
raise LookupError(f"Model {model_name} not found for model {model_type_val}")
def get_model_config_by_id(tenant_id: str, model_type: str | enum.Enum, model_id: str):
"""Get model config from tenant_model by its id (CharField PK)."""
model_type_val = model_type if isinstance(model_type, str) else model_type.value
model_type_bin = calculate_model_type(model_type_val)
exist, model_obj = TenantModelService.get_by_id(model_id)
if not exist:
raise LookupError(f"TenantModel id={model_id} not found.")
if model_obj.status == ActiveStatusEnum.INACTIVE.value:
raise LookupError(f"TenantModel id={model_id} is disabled.")
if model_obj.status == ActiveStatusEnum.UNSUPPORTED.value:
raise LookupError(f"TenantModel id={model_id} cannot be used as {model_type_val} model.")
if not (model_obj.model_type & model_type_bin):
raise LookupError(f"TenantModel id={model_id} cannot be used as {model_type_val} model.")
ok, provider_obj = TenantModelProviderService.get_by_id(model_obj.provider_id)
if not ok:
raise LookupError(f"Provider id={model_obj.provider_id} not found for model id={model_id}.")
# Validate that tenant_id owns the provider or is a joined tenant of the provider's owner.
if tenant_id != provider_obj.tenant_id:
joined_tenants = TenantService.get_joined_tenants_by_user_id(tenant_id)
joined_tenant_ids = [t["tenant_id"] for t in joined_tenants]
if provider_obj.tenant_id not in joined_tenant_ids:
raise LookupError(f"Tenant {tenant_id} has no access to provider owned by tenant {provider_obj.tenant_id}.")
ok, instance_obj = TenantModelInstanceService.get_by_id(model_obj.instance_id)
if not ok:
raise LookupError(f"Instance id={model_obj.instance_id} not found for model id={model_id}.")
View on GitHub (pinned to 554fb1133a)
Solutions
- Check tenant_model.status for the id; if UNSUPPORTED, re-add the model under a supported provider and update references.
- Verify the provider backend for that model type is available in the current deployment (image, COMPOSE_PROFILES, installed extras).
- Delete the unsupported row to stop it appearing in selectors.
- Migrate dependent datasets/assistants to a supported model id.
Defensive patterns
Strategy: try-catch
Validate before calling
exist, obj = TenantModelService.get_by_id(model_id)
if exist and obj.status == ActiveStatusEnum.UNSUPPORTED.value:
raise RuntimeError(f"Model {model_id} is unsupported in this deployment") Try / catch
try:
config = get_model_config_by_id(tenant_id, model_type, model_id)
except LookupError as e:
log.warning("unsupported model %s: %s", model_id, e)
suggest_re registration_message(e) Prevention
- After upgrades, reconcile tenant_model status against providers actually bundled in the image.
- Remove UNSUPPORTED rows so they stop appearing in selectors.
- Verify provider backends exist (compose profiles, extras) before re-adding models.
When it happens
Trigger: Calling get_model_config_by_id for a model whose tenant_model.status == ActiveStatusEnum.UNSUPPORTED — e.g. a model registered under a provider the build cannot serve, or flipped to UNSUPPORTED during provider reconciliation/upgrade.
Common situations: Upgrading RAGFlow where a provider plugin is no longer bundled; models imported from another tenant/profile whose provider backend is absent; status written by a migration that flagged legacy providers.
Related errors
- TenantModel id={model_id} is disabled.
- TenantModel id={model_id} not found.
- Model {model_name} not found for type {model_type_val}.
- Provider id={model_obj.provider_id} not found for model {mod
- Model {model_name} not found.
AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15).
Data as JSON: /api/errors/d15fc5b64563ed51.
Report an issue: GitHub.