{"record":{"id":"7dc7848bc6bb122c","repo":"alibaba/spring-ai-alibaba","slug":"modelid","errorCode":null,"errorMessage":"模型配置不存在: modelId=","messagePattern":"模型配置不存在: modelId=","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/utils/ModelConfigParser.java","lineNumber":89,"sourceCode":"                \n                ModelEntity modelEntity = null;\n                \n                // 1. 首先尝试通过 modelId (Long) 作为 ModelEntity 的 id 查找\n                if (modelConfigInfo.getModelId() != null) {\n                    modelEntity = modelManager.findModelByIdOrName(modelConfigInfo.getModelId(), workspaceId);\n                }\n                \n                // 2. 如果通过 modelId 找不到，尝试通过 modelName 查找\n                if (modelEntity == null) {\n                    String modelName = (String) modelConfigInfo.getParameter(\"modelName\");\n                    if (StringUtils.hasText(modelName)) {\n                        modelEntity = modelManager.findModelByIdOrName(modelName, workspaceId);\n                    }\n                }\n                \n                // 3. 如果还是找不到，抛出异常\n                if (modelEntity == null) {\n                    throw new IllegalArgumentException(\"模型配置不存在: modelId=\" + modelConfigInfo.getModelId() + \n                        (modelConfigInfo.getParameter(\"modelName\") != null ? \", modelName=\" + modelConfigInfo.getParameter(\"modelName\") : \"\"));\n                }\n                \n                // 如果从 ModelManager 找到了模型，更新 modelConfigInfo 的 modelId 为 ModelEntity 的 id\n                log.info(\"从 ModelManager 找到模型: id={}, name={}, modelId={}, workspaceId={}\", \n                    modelEntity.getId(), modelEntity.getName(), modelEntity.getModelId(), workspaceId);\n                \n                // 更新 modelId 为 ModelEntity 的 id，确保后续使用正确的 id\n                modelConfigInfo.setModelId(modelEntity.getId());\n            }\n        } catch (Exception e) {\n            log.error(\"解析模型配置失败: modelConfig={}\", modelConfig, e);\n            throw new RuntimeException(\"模型配置解析失败: \" + e.getMessage(), e);\n        }\n        return modelConfigInfo;\n    }\n    \n    /**","sourceCodeStart":71,"sourceCodeEnd":107,"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/utils/ModelConfigParser.java#L71-L107","documentation":"An IllegalArgumentException thrown by ModelConfigParser.checkAndGetModelConfigInfo when, after checking the config JSON and any ModelManager lookups (by id, by name), no matching ModelEntity can be found. The config parses fine but references a model that does not exist in the current workspace's model registry.","triggerScenarios":"Calling checkAndGetModelConfigInfo(modelConfig) where modelConfigInfo.getModelId() (or modelName parameter) does not match any model registered in ModelManager for the given workspaceId — the final null check on modelEntity fails.","commonSituations":"Model deleted or renamed after the prompt was saved; using a modelId from another workspace; typo in modelName parameter; deploying to an environment where the model was never registered.","solutions":["Verify the modelId/modelName exists via ModelManager.findModelByIdOrName in the target workspace and correct the config.","Re-select the model in the prompt/agent editor so the stored modelConfig points at an existing model.","Check the workspaceId being passed — the model may exist in a different workspace.","Register the referenced model in the environment before running the flow."],"exampleFix":"// before\nString cfg = \"{\\\"modelId\\\":\\\"deleted-model-id\\\"}\";\nModelConfigInfo info = parser.checkAndGetModelConfigInfo(cfg); // IAE\n// after\nif (modelManager.findModelByIdOrName(\"qwen-max\", workspaceId) != null) {\n    String cfg = \"{\\\"modelId\\\":\\\"qwen-max\\\"}\";\n    ModelConfigInfo info = parser.checkAndGetModelConfigInfo(cfg);\n}","handlingStrategy":"validation","validationCode":"ModelEntity m = modelManager.findModelByIdOrName(modelId, workspaceId);\nif (m == null) throw new BadRequestException(\"model \" + modelId + \" not found in workspace \" + workspaceId);","typeGuard":"boolean modelExists = modelManager.findModelByIdOrName(id, workspaceId) != null;","tryCatchPattern":"try { return parser.checkAndGetModelConfigInfo(cfg); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"模型配置不存在\")) { /* re-select model / fix config */ } throw e; }","preventionTips":["Validate the referenced model exists at save time, not only at run time","Scope model ids to the workspace and verify on environment changes","Watch for deleted/renamed models and update dependent prompts"],"tags":["model-config","not-found","model-registry"],"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"}