{"record":{"id":"7c477a876e3681e3","repo":"alibaba/spring-ai-alibaba","slug":"modelname","errorCode":null,"errorMessage":"模型缺少 modelName","messagePattern":"模型缺少 modelName","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/repository/impl/FileModelConfigRepository.java","lineNumber":125,"sourceCode":"            validateYamlModel(m, ids, names);\n            ModelConfigDO entity = toEntity(m);\n            map.put(entity.getId(), entity);\n        }\n        return map;\n    }\n    \n    private void validateYamlModel(YamlModel m, Set<Long> ids, Set<String> names) {\n        if (m.id == null) {\n            throw new IllegalArgumentException(\"模型缺少 id\");\n        }\n        if (m.name == null || m.name.isBlank()) {\n            throw new IllegalArgumentException(\"模型缺少 name\");\n        }\n        if (m.provider == null || m.provider.isBlank()) {\n            throw new IllegalArgumentException(\"模型缺少 provider\");\n        }\n        if (m.modelName == null || m.modelName.isBlank()) {\n            throw new IllegalArgumentException(\"模型缺少 modelName\");\n        }\n        //        if (m.baseUrl == null || m.baseUrl.isBlank()) throw new IllegalArgumentException(\"模型缺少 baseUrl\");\n        if (m.apiKey == null || m.apiKey.isBlank()) {\n            throw new IllegalArgumentException(\"模型缺少 apiKey\");\n        }\n        if (!ids.add(m.id)) {\n            throw new IllegalArgumentException(\"重复的模型 id: \" + m.id);\n        }\n        if (!names.add(m.name)) {\n            throw new IllegalArgumentException(\"重复的模型 name: \" + m.name);\n        }\n        if (m.status == null) {\n            m.status = 1;\n        }\n    }\n    \n    private ModelConfigDO toEntity(YamlModel m) {\n        ModelConfigDO.ModelConfigDOBuilder b = ModelConfigDO.builder().id(m.id).name(m.name)","sourceCodeStart":107,"sourceCodeEnd":143,"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/repository/impl/FileModelConfigRepository.java#L107-L143","documentation":"FileModelConfigRepository.validateYamlModel() throws IllegalArgumentException \"模型缺少 modelName\" (\"model missing modelName\") when the YamlModel's modelName field is null or blank. modelName is the actual upstream model identifier (e.g. qwen-max, gpt-4o) sent to the provider API and is distinct from the local display `name`.","triggerScenarios":"Loading the models YAML where an entry defines id/name/provider but no `modelName` key, or modelName is blank, so the framework cannot know which upstream model to invoke.","commonSituations":"Copying an entry and deleting modelName; confusing `name` (local alias) with `modelName` (provider model id) and only filling one; YAML key typo (model-name vs modelName) if relaxed binding is not applied.","solutions":["Add the upstream `modelName` (e.g. qwen-max) to the model entry in the YAML.","Do not confuse it with the local alias `name` — both are required.","Check the YAML key spelling/casing matches the YamlModel field (modelName).","Remove blank values (modelName: \"\")."],"exampleFix":"// before (yaml)\n  - id: 4\n    name: my-qwen\n    provider: dashscope\n// after (yaml)\n  - id: 4\n    name: my-qwen\n    provider: dashscope\n    modelName: qwen-max","handlingStrategy":"validation","validationCode":"models.forEach(m -> {\n    if (m.modelName == null || m.modelName.isBlank()) throw new IllegalArgumentException(\"model '\" + m.name + \"' missing modelName\");\n});","typeGuard":"static boolean hasModelName(YamlModel m) { return m != null && m.modelName != null && !m.modelName.isBlank(); }","tryCatchPattern":"try { repo = FileModelConfigRepository.loadFromFile(path); }\ncatch (IllegalArgumentException e) { log.error(\"Model config invalid: {}\", e.getMessage()); throw new ConfigurationException(e); }","preventionTips":["Document the difference between local alias `name` and upstream `modelName`","Validate modelName against the provider's published model list at load time","Use a YAML schema requiring all five mandatory fields","Test config changes by loading the repository in a CI job before deploy"],"tags":["yaml","validation","configuration","missing-field"],"backgroundTag":"missing-required-config-field","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"}