{"record":{"id":"83cd5b84c011f9ca","repo":"alibaba/spring-ai-alibaba","slug":"invalid-params-83cd5b","errorCode":"INVALID_PARAMS","errorMessage":"provider is invalid","messagePattern":"provider is invalid","errorType":"error_code","errorClass":"BizException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/base/manager/ModelManager.java","lineNumber":63,"sourceCode":"\n\t@Resource\n\tprivate ProviderManager providerManager;\n\n\t@Resource\n\tprivate ModelMapper modelMapper;\n\n\t/**\n\t * Add a new model\n\t * @param modelConfigInfo Model configuration information\n\t * @return true if model was added successfully\n\t */\n\tpublic boolean addModel(ModelConfigInfo modelConfigInfo) {\n\t\tRequestContext context = RequestContextHolder.getRequestContext();\n\t\t// 检查提供商是否存在\n\t\tProviderConfigInfo providerDetail = providerManager.getProviderDetail(modelConfigInfo.getProvider(), false);\n\t\tif (providerDetail == null) {\n\t\t\tlog.error(\"提供商[{}]不存在\", modelConfigInfo.getProvider());\n\t\t\tthrow new BizException(ErrorCode.INVALID_PARAMS.toError(\"input_params\", \"provider is invalid\"));\n\t\t}\n\n\t\tQueryWrapper<ModelEntity> queryWrapper = new QueryWrapper<>();\n\t\tqueryWrapper.eq(\"model_id\", modelConfigInfo.getModelId());\n\t\tqueryWrapper.eq(\"provider\", modelConfigInfo.getProvider());\n\t\tqueryWrapper.eq(\"workspace_id\", context.getWorkspaceId());\n\t\tModelEntity existModelEntity = modelMapper.selectOne(queryWrapper);\n\t\tif (existModelEntity != null) {\n\t\t\tlog.error(\"模型[{}]已存在\", modelConfigInfo.getModelId());\n\t\t\tthrow new BizException(ErrorCode.INVALID_PARAMS.toError(\"input_params\", \"model existed\"));\n\t\t}\n\n\t\tModelEntity modelEntity = new ModelEntity();\n\t\tmodelEntity.setWorkspaceId(context.getWorkspaceId());\n\t\tmodelEntity.setGmtCreate(new Date());\n\t\tmodelEntity.setGmtModified(new Date());\n\t\tmodelEntity.setIcon(modelConfigInfo.getIcon());\n\t\tmodelEntity.setName(modelConfigInfo.getName());","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/base/manager/ModelManager.java#L45-L81","documentation":"BizException thrown by ModelManager.addModel when the provider name on the submitted ModelConfigInfo cannot be resolved. The manager calls providerManager.getProviderDetail(provider, false) and if it returns null there is no registered provider config matching that name, so the request is rejected with ErrorCode.INVALID_PARAMS before any DB insert.","triggerScenarios":"Calling the add-model API (or ModelManager.addModel) with a ModelConfigInfo whose provider field is null/blank, misspelled, or names a provider that has not been registered in the workspace/provider config store.","commonSituations":"Typo in provider id in the model-registration form or JSON payload; provider was deleted or renamed before adding models; deploying to an environment where the provider config table/Nacos config was never seeded; case mismatch (e.g. 'DashScope' vs 'dashscope').","solutions":["Verify the provider exists first: call GET the provider detail API or providerManager.getProviderDetail(provider, false) and confirm a non-null result.","Fix the provider string in the request payload to exactly match a registered provider's id (check case and whitespace).","Register the provider first via the provider-management API, then retry addModel.","If the provider should exist, check you are operating in the correct workspace (RequestContext workspace) where that provider is visible."],"exampleFix":"// before\nModelConfigInfo info = new ModelConfigInfo();\ninfo.setProvider(\"dashscopoe\"); // typo\nmodelManager.addModel(info);\n// after\nModelConfigInfo info = new ModelConfigInfo();\ninfo.setProvider(\"dashscope\"); // must match a registered provider\nif (providerManager.getProviderDetail(info.getProvider(), false) == null) {\n    throw new IllegalArgumentException(\"register provider first: \" + info.getProvider());\n}\nmodelManager.addModel(info);","handlingStrategy":"validation","validationCode":"ProviderConfigInfo p = providerManager.getProviderDetail(modelConfigInfo.getProvider(), false);\nif (modelConfigInfo.getProvider() == null || modelConfigInfo.getProvider().isBlank() || p == null) {\n    throw new IllegalArgumentException(\"provider not registered: \" + modelConfigInfo.getProvider());\n}","typeGuard":"boolean isValidProvider(String provider) {\n    return provider != null && !provider.isBlank()\n        && providerManager.getProviderDetail(provider, false) != null;\n}","tryCatchPattern":"try {\n    modelManager.addModel(info);\n} catch (BizException e) {\n    if (e.getError() != null && \"provider is invalid\".equals(e.getError().getMessage())) {\n        log.warn(\"Unknown provider {}\", info.getProvider()); // surface 400 with hint\n    } else {\n        throw e;\n    }\n}","preventionTips":["Validate provider against the provider list API before submitting model config.","Copy provider ids from the provider registry UI/API instead of typing them.","Enforce a dropdown of registered providers in any model-registration UI.","Seed provider config as part of environment bootstrap so all envs have the same providers."],"tags":["validation","provider","invalid-params","spring-ai-alibaba"],"backgroundTag":"invalid-argument-value","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"}