alibaba/spring-ai-alibaba · warning
找到ModelConfigInfo但未找到对应的ModelEntity: provider={}, modelId={}
Error message
找到ModelConfigInfo但未找到对应的ModelEntity: provider={}, modelId={} What it means
convertModelConfigInfoToModelConfigDO could not resolve a ModelEntity matching the ModelConfigInfo's provider/modelId, so it falls back to buildModelConfigDOFromModelConfigInfo with a null id. The conversion still returns a usable DO for inference (baseUrl, apiKey) but the record lacks a registry id.
Source
Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/service/impl/ModelConfigBridgeServiceImpl.java:317
if (provider.equals(entity.getProvider()) && modelId.equals(entity.getModelId())) {
return convertToModelConfigDO(entity);
}
}
// 如果还是找不到,尝试从queryModels中查找
List<ModelConfigInfo> models = modelManager.queryModels(provider);
for (ModelConfigInfo model : models) {
if (modelId.equals(model.getModelId())) {
// 再次尝试查找ModelEntity
modelEntity = modelManager.findModelByIdOrName(modelId, workspaceId);
if (modelEntity != null && provider.equals(modelEntity.getProvider())) {
return convertToModelConfigDO(modelEntity);
}
}
}
// 如果找不到ModelEntity,使用ModelConfigInfo构建(但缺少id)
log.warn("找到ModelConfigInfo但未找到对应的ModelEntity: provider={}, modelId={}",
provider, modelId);
return buildModelConfigDOFromModelConfigInfo(modelConfigInfo, null);
} catch (Exception e) {
log.error("转换ModelConfigInfo到ModelConfigDO失败: provider={}, modelId={}",
modelConfigInfo.getProvider(), modelConfigInfo.getModelId(), e);
return null;
}
}
/**
* 从ModelConfigInfo构建ModelConfigDO(当找不到ModelEntity时使用)
*/
private ModelConfigDO buildModelConfigDOFromModelConfigInfo(ModelConfigInfo modelConfigInfo, Long id) {
try {
ProviderConfigInfo providerDetail = providerManager.getProviderDetail(modelConfigInfo.getProvider(), false);
if (providerDetail == null) {
return null;
}View on GitHub (pinned to f82da0b50f)
Solutions
- Register the model as a ModelEntity with exactly matching provider and modelId
- Compare provider/modelId strings for exact (case-sensitive) equality between the config source and the model registry
- Use the returned DO only for read/inference purposes; avoid id-based persistence operations since id is null
- Check any entity filters (enabled, workspace) used in the lookup path
Example fix
// before
ModelConfigDO config = bridgeService.convertModelConfigInfoToModelConfigDO(info);
repo.update(config.getId(), config); // id is null
// after
ModelConfigDO config = bridgeService.convertModelConfigInfoToModelConfigDO(info);
if (config.getId() == null) { config = repo.create(config); } // register first Defensive patterns
Strategy: type-guard
Type guard
boolean hasRegistryId(ModelConfigDO c) { return c != null && c.getId() != null; } Prevention
- Register a ModelEntity before using its config for persistence flows
- Verify provider/modelId equality across stores
- Avoid id-based operations on the fallback-built DO
When it happens
Trigger: Calling convertModelConfigInfoToModelConfigDO for a config whose provider/modelId has no enabled ModelEntity row — e.g. model defined only in remote ModelConfigInfo storage.
Common situations: Model exists in imported/synced config but was never registered as a model entity; entity disabled or filtered out; string mismatch between provider/modelId in the two stores.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- 找到ModelConfigInfo但未找到对应的ModelEntity,使用ModelConfigInfo构建: pro
- 模型缺少 apiKey
- 序列化 defaultParameters 失败
- 序列化 supportedParameters 失败
- 模型配置不存在:
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/68fd9b436044b9ab.
Report an issue: GitHub.