{"record":{"id":"3198eefff986fdfe","repo":"alibaba/spring-ai-alibaba","slug":"error-3198ee","errorCode":null,"errorMessage":"不支持的模型提供商: ","messagePattern":"不支持的模型提供商: ","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/service/client/ChatClientFactoryDelegate.java","lineNumber":101,"sourceCode":"        \n        if (config == null) {\n            throw new RuntimeException(\"模型配置不存在: \" + modelConfigId);\n        }\n        \n        if (config.getStatus() != 1) {\n            throw new RuntimeException(\"模型配置已禁用: \" + modelConfigId);\n        }\n\n        String provider = config.getProvider().toLowerCase();\n        log.info(\"创建模型客户端，提供商: {}, 模型: {}\", provider, config.getModelName());\n        \n        ChatClientFactory factory = chatClientFactories.get(provider);\n        if (factory == null) {\n            // 如果找不到对应的 provider factory，默认使用 OpenAI\n            log.warn(\"未找到提供商 {} 对应的工厂，使用默认的 OpenAI 工厂\", provider);\n            factory = chatClientFactories.get(OpenAiChatClientFactory.OPEN_AI_PROVIDER);\n            if (factory == null) {\n                throw new UnsupportedOperationException(\"不支持的模型提供商: \" + config.getProvider() + \"，且默认的 OpenAI 工厂也不可用\");\n            }\n        }\n        \n        ChatModel chatModel = factory.buildChatModel(config);\n        Map<String, Object> mergedParameters = mergeParameters(config, userParameters);\n        ChatOptions options = factory.buildChatOptions(config, mergedParameters, observationMetadata);\n        if (advisors != null) {\n            return ChatClient.builder(chatModel,observationRegistry,customObservationConvention,\n                            new DefaultAdvisorObservationConvention()).defaultOptions(options).defaultAdvisors(advisors)\n                    .build();\n        } else {\n            return ChatClient.builder(chatModel,observationRegistry,customObservationConvention\n                    ,new DefaultAdvisorObservationConvention()).defaultOptions(options).defaultAdvisors().build();\n\n        }\n    }\n    \n    /**","sourceCodeStart":83,"sourceCodeEnd":119,"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/client/ChatClientFactoryDelegate.java#L83-L119","documentation":"createChatClient resolves a ChatClientFactory from chatClientFactories by provider name; if absent it logs a warning and falls back to the OpenAI factory. If even the OpenAI factory bean is missing, it throws this UnsupportedOperationException naming the provider. This indicates the Spring context lacks the fallback factory bean.","triggerScenarios":"Calling createChatClient with a config whose provider string has no registered ChatClientFactory AND the OpenAiChatClientFactory (OPEN_AI_PROVIDER) is not present in chatClientFactories — e.g., the OpenAI starter/auto-configuration is not on the classpath or the factory bean failed to register.","commonSituations":"Typo in the provider field of the model config (e.g., 'openAi ' with whitespace/case issues after toLowerCase); OpenAI factory excluded from the Spring context; running a trimmed deployment without the OpenAI client dependency while configs still reference non-OpenAI providers.","solutions":["Check the provider value in the model config for typos and match it exactly to a registered factory (e.g., 'openai', 'dashscope')","Ensure the OpenAI chat client factory bean is registered (include the corresponding dependency/starter and verify auto-configuration)","Register a ChatClientFactory for the custom provider before creating clients","Inspect chatClientFactories contents (via logs/debug) to confirm which providers are available at runtime"],"exampleFix":"// before (models.yml)\nprovider: open-ai   # no factory, and OpenAI fallback missing\n// after\nprovider: openai    # matches OpenAiChatClientFactory.OPEN_AI_PROVIDER","handlingStrategy":"fallback","validationCode":"// Java: ensure a factory exists for the provider (or OpenAI fallback) before building\n// (exposed via logs: '未找到提供商 {} 对应的工厂') — verify provider string matches a registered factory","typeGuard":"boolean providerSupported(String provider, Map<String, ChatClientFactory> factories) {\n    return provider != null && (factories.containsKey(provider.toLowerCase())\n        || factories.containsKey(OpenAiChatClientFactory.OPEN_AI_PROVIDER));\n}","tryCatchPattern":"try {\n    client = delegate.createChatClient(modelConfigId, params, metadata);\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage().startsWith(\"不支持的模型提供商\")) {\n        log.error(\"Provider missing factory and OpenAI fallback unavailable: {}\", e.getMessage());\n    }\n}","preventionTips":["Keep the OpenAI factory dependency/starter on the classpath so the fallback always exists","Validate the provider field against the supported provider list at config load time","Register a ChatClientFactory for every custom provider used in the environment"],"tags":["unsupported-provider","factory","configuration","dependency"],"backgroundTag":"unsupported-operation","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}