alibaba/spring-ai-alibaba · error · BizException

MISSING_PARAMS

MISSING_PARAMS

Error message

request or taskId is null

What it means

BizException thrown by ChatController.getAsyncResults when the request body or its taskId field is null. The endpoint retrieves a workflow context from Redis using workspaceId + taskId, so both must be present before the lookup can proceed. The error carries code MISSING_PARAMS and names the missing piece in its message.

Source

Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-openapi/src/main/java/com/alibaba/cloud/ai/studio/controller/ChatController.java:329

	@PostMapping(value = { "/workflow/stop-completions" })
	public Result<Boolean> stopCompletion(@RequestBody TaskStopRequest request) {
		long start = System.currentTimeMillis();
		RequestContext requestContext = RequestContextHolder.getRequestContext();
		if (request == null || StringUtils.isBlank(request.getTaskId())) {
			return Result.error(requestContext.getRequestId(), ErrorCode.MISSING_PARAMS.toError("taskId is null"));
		}
		return Result.success(workflowService.stop(request));
	}

	@PostMapping(value = { "/workflow/async-results" })
	public Result<AsyncResultResponse> getAsyncResults(@RequestBody AsyncResultRequest request) {
		long start = System.currentTimeMillis();
		RequestContext context = RequestContextHolder.getRequestContext();
		context.setStartTime(System.currentTimeMillis());

		try {
			if (request == null || request.getTaskId() == null) {
				throw new BizException(ErrorCode.MISSING_PARAMS.toError("request or taskId is null"));
			}

			// 从Redis中获取工作流上下文
			String cacheKey = WORKFLOW_TASK_CONTEXT_PREFIX + context.getWorkspaceId() + "_" + request.getTaskId();
			WorkflowContext wfContext = redisManager.get(cacheKey);

			if (wfContext == null) {
				log.info("Async task not found: taskId={}, workspaceId={}, requestId={}", request.getTaskId(),
						context.getWorkspaceId(), context.getRequestId());
				return Result.error(context.getRequestId(),
						ErrorCode.WORKFLOW_CONFIG_INVALID.toError("taskId not exists"));
			}

			// 构建响应对象
			AsyncResultResponse response = new AsyncResultResponse();
			response.setTaskId(request.getTaskId());
			response.setRequestId(wfContext.getRequestId());
			response.setConversationId(wfContext.getConversationId());

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Include a valid taskId in the request body before calling getAsyncResults.
  2. Verify the JSON property name matches the request DTO field (taskId) exactly, including Jackson naming strategy.
  3. Client-side, check request != null && request.getTaskId() != null before sending the polling call.
  4. Capture the taskId returned when the async task was originally submitted and use that value.

Example fix

// before
POST /chat/async/results
{}

// after
POST /chat/async/results
{"taskId": "b1c2d3e4-..."}
Defensive patterns

Strategy: validation

Validate before calling

if (request == null || request.getTaskId() == null || request.getTaskId().isBlank()) {
  throw new IllegalStateException("taskId is required to poll async results");
}

Type guard

boolean hasTaskId(ChatAsyncRequest r) { return r != null && r.getTaskId() != null && !r.getTaskId().isBlank(); }

Try / catch

try {
  results = chatClient.getAsyncResults(req);
} catch (BizException e) {
  if ("MISSING_PARAMS".equals(e.getCode())) { /* re-submit task or recover taskId */ }
}

Prevention

When it happens

Trigger: Calling the async-results chat endpoint with an empty/missing JSON body, or with a body whose taskId property is null (e.g. JSON omitted "taskId" or sent as null).

Common situations: Clients polling for async results with a stale or never-created task id field; deserialization quirks where the JSON property name doesn't match the DTO field so taskId stays null; hand-crafted curl/test calls forgetting the taskId.

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/4b0387ad950a7e15. Report an issue: GitHub.