{"record":{"id":"68fd9b436044b9ab","repo":"alibaba/spring-ai-alibaba","slug":"modelconfiginfo-modelentity-provider","errorCode":null,"errorMessage":"找到ModelConfigInfo但未找到对应的ModelEntity: provider={}, modelId={}","messagePattern":"找到ModelConfigInfo但未找到对应的ModelEntity: provider=(.+?), modelId=(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/service/impl/ModelConfigBridgeServiceImpl.java","lineNumber":317,"sourceCode":"                if (provider.equals(entity.getProvider()) && modelId.equals(entity.getModelId())) {\n                    return convertToModelConfigDO(entity);\n                }\n            }\n            \n            // 如果还是找不到，尝试从queryModels中查找\n            List<ModelConfigInfo> models = modelManager.queryModels(provider);\n            for (ModelConfigInfo model : models) {\n                if (modelId.equals(model.getModelId())) {\n                    // 再次尝试查找ModelEntity\n                    modelEntity = modelManager.findModelByIdOrName(modelId, workspaceId);\n                    if (modelEntity != null && provider.equals(modelEntity.getProvider())) {\n                        return convertToModelConfigDO(modelEntity);\n                    }\n                }\n            }\n\n            // 如果找不到ModelEntity，使用ModelConfigInfo构建（但缺少id）\n            log.warn(\"找到ModelConfigInfo但未找到对应的ModelEntity: provider={}, modelId={}\", \n                provider, modelId);\n            return buildModelConfigDOFromModelConfigInfo(modelConfigInfo, null);\n        } catch (Exception e) {\n            log.error(\"转换ModelConfigInfo到ModelConfigDO失败: provider={}, modelId={}\", \n                modelConfigInfo.getProvider(), modelConfigInfo.getModelId(), e);\n            return null;\n        }\n    }\n\n    /**\n     * 从ModelConfigInfo构建ModelConfigDO（当找不到ModelEntity时使用）\n     */\n    private ModelConfigDO buildModelConfigDOFromModelConfigInfo(ModelConfigInfo modelConfigInfo, Long id) {\n        try {\n            ProviderConfigInfo providerDetail = providerManager.getProviderDetail(modelConfigInfo.getProvider(), false);\n            if (providerDetail == null) {\n                return null;\n            }","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/service/impl/ModelConfigBridgeServiceImpl.java#L299-L335","documentation":"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.","triggerScenarios":"Calling convertModelConfigInfoToModelConfigDO for a config whose provider/modelId has no enabled ModelEntity row — e.g. model defined only in remote ModelConfigInfo storage.","commonSituations":"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.","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"],"exampleFix":"// before\nModelConfigDO config = bridgeService.convertModelConfigInfoToModelConfigDO(info);\nrepo.update(config.getId(), config); // id is null\n// after\nModelConfigDO config = bridgeService.convertModelConfigInfoToModelConfigDO(info);\nif (config.getId() == null) { config = repo.create(config); } // register first","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"boolean hasRegistryId(ModelConfigDO c) { return c != null && c.getId() != null; }","tryCatchPattern":null,"preventionTips":["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"],"tags":["model-config","entity-not-found","data-consistency"],"backgroundTag":"entity-not-found","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}