{"record":{"id":"3ae55c23e8df8b13","repo":"alibaba/spring-ai-alibaba","slug":"name-3ae55c","errorCode":null,"errorMessage":"模型缺少 name","messagePattern":"模型缺少 name","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":119,"sourceCode":"        }\n        \n        Map<Long, ModelConfigDO> map = new HashMap<>();\n        Set<Long> ids = new HashSet<>();\n        Set<String> names = new HashSet<>();\n        for (YamlModel m : root.models) {\n            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) {","sourceCodeStart":101,"sourceCodeEnd":137,"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#L101-L137","documentation":"FileModelConfigRepository.validateYamlModel() throws IllegalArgumentException \"模型缺少 name\" (\"model missing name\") when a parsed YamlModel has a null or blank name. The name is a required, non-blank identifier for the model and is also used in duplicate-name detection.","triggerScenarios":"Loading the models YAML when a model entry has no `name` key, or name is present but empty/whitespace (name: \"\" or name: \"   \").","commonSituations":"Adding a new model block and leaving name blank; YAML anchoring/templating producing empty strings; accidental deletion of the name line during editing.","solutions":["Add a non-blank `name` value to every model entry in the YAML file.","Check for entries with name: \"\" or only whitespace and fill them in.","Ensure indentation places `name` under the correct model entry.","Also ensure the name is unique — duplicate names are rejected by the names set."],"exampleFix":"// before (yaml)\n  - id: 2\n    name: \"\"\n// after (yaml)\n  - id: 2\n    name: qwen-max","handlingStrategy":"validation","validationCode":"models.forEach(m -> {\n    if (m.name == null || m.name.isBlank()) throw new IllegalArgumentException(\"model id=\" + m.id + \" missing name\");\n});","typeGuard":"static boolean hasName(YamlModel m) { return m != null && m.name != null && !m.name.isBlank(); }","tryCatchPattern":"try { repo = FileModelConfigRepository.loadFromFile(path); }\ncatch (IllegalArgumentException e) { log.error(\"Model config invalid: {}\", e.getMessage()); throw new ConfigurationException(e); }","preventionTips":["Reject blank strings, not just null, when validating YAML text fields","Enforce unique names in CI along with presence checks","Document that `name` is the local alias and must be human-meaningful","Fail fast at config load time rather than at first model use"],"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"}