alibaba/spring-ai-alibaba · warning

找到ModelConfigInfo但未找到对应的ModelEntity,使用ModelConfigInfo构建: pro

Error message

找到ModelConfigInfo但未找到对应的ModelEntity,使用ModelConfigInfo构建: provider={}, modelId={}

What it means

This warning is logged by ModelConfigBridgeServiceImpl.findByProviderAndModelId when a ModelConfigInfo record matching the provider/modelId was found, but no corresponding enabled ModelEntity exists in the model registry. Since the entity carries the primary id, the bridge builds a ModelConfigDO from the ModelConfigInfo alone with a null id, so the returned config cannot be used for id-based updates or lookups.

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:193

            for (ModelConfigInfo model : models) {
                if (modelId.equals(model.getModelId())) {
                    // 找到了匹配的ModelConfigInfo,现在需要获取对应的ModelEntity
                    String workspaceId = getWorkspaceId();
                    // 尝试通过modelId查找(可能是name或model_id)
                    ModelEntity modelEntity = modelManager.findModelByIdOrName(modelId, workspaceId);
                    // 验证provider是否匹配
                    if (modelEntity != null && provider.equals(modelEntity.getProvider())) {
                        return convertToModelConfigDO(modelEntity);
                    }
                    // 如果找不到,尝试从queryEnabledModelEntities中查找
                    List<ModelEntity> enabledEntities = modelManager.queryEnabledModelEntities();
                    for (ModelEntity entity : enabledEntities) {
                        if (provider.equals(entity.getProvider()) && modelId.equals(entity.getModelId())) {
                            return convertToModelConfigDO(entity);
                        }
                    }
                    // 如果还是找不到,使用ModelConfigInfo构建(但缺少id)
                    log.warn("找到ModelConfigInfo但未找到对应的ModelEntity,使用ModelConfigInfo构建: provider={}, modelId={}", 
                        provider, modelId);
                    return buildModelConfigDOFromModelConfigInfo(model, null);
                }
            }
            return null;
        } catch (Exception e) {
            log.error("根据provider和modelId查找模型配置失败: provider={}, modelId={}", provider, modelId, e);
            return null;
        }
    }

    /**
     * 将ModelEntity转换为ModelConfigDO
     */
    private ModelConfigDO convertToModelConfigDO(ModelEntity modelEntity) {
        if (modelEntity == null) {
            return null;
        }

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Create or enable the corresponding ModelEntity in the model management UI/API so provider and modelId match the ModelConfigInfo exactly
  2. Verify provider and modelId strings match exactly (case-sensitive) between ModelConfigInfo and ModelEntity stores
  3. If only the DO without id is needed, treat the null id as expected and avoid id-based operations on the result
  4. Check that any filtering (enabled flag, workspace) is not excluding the entity

Example fix

// before: ModelConfigDO with null id used in update flow
ModelConfigDO config = bridgeService.findByProviderAndModelId("dashscope", "qwen-max");
modelService.update(config.getId(), ...); // NPE / no-op
// after: check id first
ModelConfigDO config = bridgeService.findByProviderAndModelId("dashscope", "qwen-max");
if (config == null || config.getId() == null) { registerModelEntity("dashscope", "qwen-max"); }
Defensive patterns

Strategy: validation

Validate before calling

if (entityRepository.existsByProviderAndModelIdAndEnabled(provider, modelId)) { /* safe to call */ }

Type guard

boolean isRegistered(ModelConfigDO c) { return c != null && c.getId() != null; }

Prevention

When it happens

Trigger: Calling findByProviderAndModelId(provider, modelId) where the model exists in ModelConfigInfo storage (e.g. synced config) but no enabled ModelEntity row matches both the provider and modelId values exactly — including case/string mismatches.

Common situations: Model was registered in Nacos/remote config but never created as a ModelEntity in the admin database; the model entity is disabled; provider name or modelId string differs slightly (case, version suffix) between 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


AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09). Data as JSON: /api/errors/aaa82d991a66eee2. Report an issue: GitHub.