{"record":{"id":"1b5a08e8270b047a","repo":"alibaba/spring-ai-alibaba","slug":"provider","errorCode":null,"errorMessage":"模型缺少 provider","messagePattern":"模型缺少 provider","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":122,"sourceCode":"        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) {\n            m.status = 1;\n        }\n    }","sourceCodeStart":104,"sourceCodeEnd":140,"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#L104-L140","documentation":"FileModelConfigRepository.validateYamlModel() throws IllegalArgumentException \"模型缺少 provider\" (\"model missing provider\") when a YamlModel's provider field is null or blank. The provider identifies which model service (e.g. dashscope, openai, deepseek) serves the model and is required for building the runtime model client.","triggerScenarios":"Loading the models YAML with a model entry that lacks the `provider` key or has it blank, typically a hand-authored or partially copied entry.","commonSituations":"Writing a new model entry from scratch and forgetting provider; renaming provider keys during a config migration; YAML indentation nesting provider under the wrong entry.","solutions":["Add a valid `provider` (e.g. dashscope, openai) to every model entry in the YAML.","Verify provider spelling matches the provider identifiers supported by the framework.","Fix indentation so provider belongs to the intended model entry.","Remove empty provider values (provider: \"\")."],"exampleFix":"// before (yaml)\n  - id: 3\n    name: gpt4\n    modelName: gpt-4o\n// after (yaml)\n  - id: 3\n    name: gpt4\n    provider: openai\n    modelName: gpt-4o","handlingStrategy":"validation","validationCode":"models.forEach(m -> {\n    if (m.provider == null || m.provider.isBlank()) throw new IllegalArgumentException(\"model '\" + m.name + \"' missing provider\");\n});","typeGuard":"static boolean hasProvider(YamlModel m) { return m != null && m.provider != null && !m.provider.isBlank(); }","tryCatchPattern":"try { repo = FileModelConfigRepository.loadFromFile(path); }\ncatch (IllegalArgumentException e) { log.error(\"Model config invalid: {}\", e.getMessage()); throw new ConfigurationException(e); }","preventionTips":["Maintain a whitelist of supported provider ids and validate against it","Copy full entry templates when adding new models","Validate the whole YAML file in CI with a schema","Check provider spelling against framework-recognized identifiers"],"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"}