alibaba/spring-ai-alibaba · error · BizException

MISSING_PARAMS

MISSING_PARAMS

Error message

Required parameters [apiKey] missing, please check the request parameters.

What it means

MISSING_PARAMS BizException from ApiKeyController.createApiKey, thrown when the @RequestBody ApiKey object is null. A required @RequestBody is normally enforced by Spring (400 if body absent), so a null here indicates the body resolved to null under non-standard invocation or configuration. The create endpoint needs an ApiKey payload containing at least a description.

Source

Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/builder/controller/ApiKeyController.java:61

	/** Service for handling API key operations */
	private final ApiKeyService apiKeyService;

	public ApiKeyController(ApiKeyService apiKeyService) {
		this.apiKeyService = apiKeyService;
	}

	/**
	 * Creates a new API key
	 * @param apiKey API key information
	 * @return Result containing the created API key ID
	 */
	@PostMapping()
	public Result<String> createApiKey(@RequestBody ApiKey apiKey) {
		RequestContext context = RequestContextHolder.getRequestContext();

		if (Objects.isNull(apiKey)) {
			throw new BizException(ErrorCode.MISSING_PARAMS.toError("apiKey"));
		}

		if (StringUtils.isBlank(apiKey.getDescription())) {
			throw new BizException(ErrorCode.MISSING_PARAMS.toError("description"));
		}

		Long id = apiKeyService.createApiKey(apiKey);
		return Result.success(context.getRequestId(), String.valueOf(id));
	}

	/**
	 * Updates an existing API key
	 * @param id API key ID
	 * @param apiKey Updated API key information
	 * @return Result indicating success
	 */
	@PutMapping("/{id}")
	public Result<String> updateApiKey(@PathVariable("id") Long id, @RequestBody ApiKey apiKey) {

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Send a JSON body: {"description": "..."} with Content-Type: application/json.
  2. Ensure the body is non-empty.
  3. Call createApiKey(new ApiKey()) in tests rather than null.
  4. Verify Spring's required-body enforcement is not disabled.

Example fix

// before
post("/api-keys", null);
// after
post("/api-keys", "{\"description\": \"prod key\"}");
Defensive patterns

Strategy: validation

Validate before calling

if (apiKey == null || apiKey.getDescription() == null || apiKey.getDescription().isBlank()) { throw new IllegalArgumentException("apiKey body with description is required"); }

Type guard

boolean hasApiKeyBody(ApiKey k) { return k != null; }

Try / catch

try {
    String id = apiKeyApi.createApiKey(key);
} catch (BizException e) {
    if ("MISSING_PARAMS".equals(e.getCode())) {
        throw new IllegalArgumentException("API key payload is required", e);
    }
}

Prevention

When it happens

Trigger: POST /api-keys with no/empty body under permissive config, or direct invocation createApiKey(null).

Common situations: Missing Content-Type: application/json header; empty request body; tests calling the handler directly with null.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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