alibaba/spring-ai-alibaba · error · BizException

INVALID_PARAMS

INVALID_PARAMS

Error message

provider is invalid

What it means

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.

Source

Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/base/manager/ModelManager.java:63

	@Resource
	private ProviderManager providerManager;

	@Resource
	private ModelMapper modelMapper;

	/**
	 * Add a new model
	 * @param modelConfigInfo Model configuration information
	 * @return true if model was added successfully
	 */
	public boolean addModel(ModelConfigInfo modelConfigInfo) {
		RequestContext context = RequestContextHolder.getRequestContext();
		// 检查提供商是否存在
		ProviderConfigInfo providerDetail = providerManager.getProviderDetail(modelConfigInfo.getProvider(), false);
		if (providerDetail == null) {
			log.error("提供商[{}]不存在", modelConfigInfo.getProvider());
			throw new BizException(ErrorCode.INVALID_PARAMS.toError("input_params", "provider is invalid"));
		}

		QueryWrapper<ModelEntity> queryWrapper = new QueryWrapper<>();
		queryWrapper.eq("model_id", modelConfigInfo.getModelId());
		queryWrapper.eq("provider", modelConfigInfo.getProvider());
		queryWrapper.eq("workspace_id", context.getWorkspaceId());
		ModelEntity existModelEntity = modelMapper.selectOne(queryWrapper);
		if (existModelEntity != null) {
			log.error("模型[{}]已存在", modelConfigInfo.getModelId());
			throw new BizException(ErrorCode.INVALID_PARAMS.toError("input_params", "model existed"));
		}

		ModelEntity modelEntity = new ModelEntity();
		modelEntity.setWorkspaceId(context.getWorkspaceId());
		modelEntity.setGmtCreate(new Date());
		modelEntity.setGmtModified(new Date());
		modelEntity.setIcon(modelConfigInfo.getIcon());
		modelEntity.setName(modelConfigInfo.getName());

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Verify the provider exists first: call GET the provider detail API or providerManager.getProviderDetail(provider, false) and confirm a non-null result.
  2. Fix the provider string in the request payload to exactly match a registered provider's id (check case and whitespace).
  3. Register the provider first via the provider-management API, then retry addModel.
  4. If the provider should exist, check you are operating in the correct workspace (RequestContext workspace) where that provider is visible.

Example fix

// before
ModelConfigInfo info = new ModelConfigInfo();
info.setProvider("dashscopoe"); // typo
modelManager.addModel(info);
// after
ModelConfigInfo info = new ModelConfigInfo();
info.setProvider("dashscope"); // must match a registered provider
if (providerManager.getProviderDetail(info.getProvider(), false) == null) {
    throw new IllegalArgumentException("register provider first: " + info.getProvider());
}
modelManager.addModel(info);
Defensive patterns

Strategy: validation

Validate before calling

ProviderConfigInfo p = providerManager.getProviderDetail(modelConfigInfo.getProvider(), false);
if (modelConfigInfo.getProvider() == null || modelConfigInfo.getProvider().isBlank() || p == null) {
    throw new IllegalArgumentException("provider not registered: " + modelConfigInfo.getProvider());
}

Type guard

boolean isValidProvider(String provider) {
    return provider != null && !provider.isBlank()
        && providerManager.getProviderDetail(provider, false) != null;
}

Try / catch

try {
    modelManager.addModel(info);
} catch (BizException e) {
    if (e.getError() != null && "provider is invalid".equals(e.getError().getMessage())) {
        log.warn("Unknown provider {}", info.getProvider()); // surface 400 with hint
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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').

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09). Data as JSON: /api/errors/83cd5b84c011f9ca. Report an issue: GitHub.