{"record":{"id":"aaa82d991a66eee2","repo":"alibaba/spring-ai-alibaba","slug":"modelconfiginfo-modelentity-modelconfigi","errorCode":null,"errorMessage":"找到ModelConfigInfo但未找到对应的ModelEntity，使用ModelConfigInfo构建: provider={}, modelId={}","messagePattern":"找到ModelConfigInfo但未找到对应的ModelEntity，使用ModelConfigInfo构建: 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":193,"sourceCode":"            for (ModelConfigInfo model : models) {\n                if (modelId.equals(model.getModelId())) {\n                    // 找到了匹配的ModelConfigInfo，现在需要获取对应的ModelEntity\n                    String workspaceId = getWorkspaceId();\n                    // 尝试通过modelId查找（可能是name或model_id）\n                    ModelEntity modelEntity = modelManager.findModelByIdOrName(modelId, workspaceId);\n                    // 验证provider是否匹配\n                    if (modelEntity != null && provider.equals(modelEntity.getProvider())) {\n                        return convertToModelConfigDO(modelEntity);\n                    }\n                    // 如果找不到，尝试从queryEnabledModelEntities中查找\n                    List<ModelEntity> enabledEntities = modelManager.queryEnabledModelEntities();\n                    for (ModelEntity entity : enabledEntities) {\n                        if (provider.equals(entity.getProvider()) && modelId.equals(entity.getModelId())) {\n                            return convertToModelConfigDO(entity);\n                        }\n                    }\n                    // 如果还是找不到，使用ModelConfigInfo构建（但缺少id）\n                    log.warn(\"找到ModelConfigInfo但未找到对应的ModelEntity，使用ModelConfigInfo构建: provider={}, modelId={}\", \n                        provider, modelId);\n                    return buildModelConfigDOFromModelConfigInfo(model, null);\n                }\n            }\n            return null;\n        } catch (Exception e) {\n            log.error(\"根据provider和modelId查找模型配置失败: provider={}, modelId={}\", provider, modelId, e);\n            return null;\n        }\n    }\n\n    /**\n     * 将ModelEntity转换为ModelConfigDO\n     */\n    private ModelConfigDO convertToModelConfigDO(ModelEntity modelEntity) {\n        if (modelEntity == null) {\n            return null;\n        }","sourceCodeStart":175,"sourceCodeEnd":211,"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#L175-L211","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Create or enable the corresponding ModelEntity in the model management UI/API so provider and modelId match the ModelConfigInfo exactly","Verify provider and modelId strings match exactly (case-sensitive) between ModelConfigInfo and ModelEntity stores","If only the DO without id is needed, treat the null id as expected and avoid id-based operations on the result","Check that any filtering (enabled flag, workspace) is not excluding the entity"],"exampleFix":"// before: ModelConfigDO with null id used in update flow\nModelConfigDO config = bridgeService.findByProviderAndModelId(\"dashscope\", \"qwen-max\");\nmodelService.update(config.getId(), ...); // NPE / no-op\n// after: check id first\nModelConfigDO config = bridgeService.findByProviderAndModelId(\"dashscope\", \"qwen-max\");\nif (config == null || config.getId() == null) { registerModelEntity(\"dashscope\", \"qwen-max\"); }","handlingStrategy":"validation","validationCode":"if (entityRepository.existsByProviderAndModelIdAndEnabled(provider, modelId)) { /* safe to call */ }","typeGuard":"boolean isRegistered(ModelConfigDO c) { return c != null && c.getId() != null; }","tryCatchPattern":null,"preventionTips":["Keep ModelConfigInfo and ModelEntity registries in sync (register entity on config import)","Match provider/modelId strings exactly, including case","Check the returned DO's id for null before id-based operations"],"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"}