{"record":{"id":"9983987fca960ca9","repo":"alibaba/spring-ai-alibaba","slug":"error-998398","errorCode":null,"errorMessage":"模型配置已禁用: ","messagePattern":"模型配置已禁用: ","errorType":"exception","errorClass":"RuntimeException","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":89,"sourceCode":"        return createChatClient(modelConfigId, userParameters, null, observationMetadata);\n    }\n    \n    public ChatClient createChatClient(Long modelConfigId, Map<String, Object> userParameters, List<Advisor> advisors, Map<String, String> observationMetadata) {\n        // 优先从桥接服务查找（从Manager层查询）\n        ModelConfigDO config = modelConfigBridgeService.findById(modelConfigId);\n        \n        // 如果桥接服务中找不到，尝试从ModelConfigRepository查找（保持向后兼容）\n        if (config == null) {\n            log.debug(\"桥接服务中未找到模型配置 id={}，尝试从 ModelConfigRepository 查找\", modelConfigId);\n            config = modelConfigRepository.findById(modelConfigId);\n        }\n        \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);","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/service/client/ChatClientFactoryDelegate.java#L71-L107","documentation":"After locating the model config, createChatClient checks config.getStatus() != 1 and throws this RuntimeException when the model is disabled (any status other than 1, which means enabled). Disabled models must not be used to create chat clients, so the call is rejected.","triggerScenarios":"Calling createChatClient for a modelConfigId whose config record has status set to 0 (disabled) in the YAML file or the model config store.","commonSituations":"An admin disabled the model in the admin UI while sessions still reference it; a YAML entry has status: 0; a model was temporarily disabled for cost/quota reasons but old code paths still use it.","solutions":["Re-enable the model: set status: 1 in the models YAML or toggle it on in the admin UI","Choose a different, enabled model config id for the session or request","Refresh sessions that cached the disabled config so they resolve the updated status","Add pre-checks in calling code (config.getStatus() == 1) to fail gracefully instead of at client creation"],"exampleFix":"// before (models.yml)\n- id: 1\n  name: qwen-max\n  status: 0\n// after\n- id: 1\n  name: qwen-max\n  status: 1","handlingStrategy":"validation","validationCode":"// Java: verify enabled status before creating a client\nModelConfigDO cfg = modelConfigRepository.findById(modelConfigId);\nif (cfg == null || cfg.getStatus() == null || cfg.getStatus() != 1) {\n    throw new IllegalStateException(\"Model \" + modelConfigId + \" is missing or disabled\");\n}","typeGuard":"boolean isEnabled(ModelConfigDO c) { return c != null && Integer.valueOf(1).equals(c.getStatus()); }","tryCatchPattern":"try {\n    client = delegate.createChatClient(modelConfigId, params, metadata);\n} catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"模型配置已禁用\")) {\n        // fall back to another enabled model or surface a user-facing message\n    }\n}","preventionTips":["Cache-free re-check of status before each client creation; don't persist status snapshots","Notify/refresh sessions when an admin disables a model","Maintain at least one always-enabled fallback model per environment"],"tags":["disabled","model-config","invalid-state"],"backgroundTag":"invalid-config-value","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}