alibaba/spring-ai-alibaba · error · ResponseStatusException

appName cannot be null or empty

Error message

appName cannot be null or empty

What it means

ExecutionController.agentRunSse validates the SSE run request and rejects it with HTTP 400 (ResponseStatusException BAD_REQUEST) when appName is null or blank, emitting the error through the returned Flux. A run cannot start without knowing which registered app/agent to execute.

Source

Thrown at spring-ai-alibaba-studio/src/main/java/com/alibaba/cloud/ai/agent/studio/controller/ExecutionController.java:163

//			return Flux.error(new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Agent run failed", e));
//		}
//	}

	/**
	 * Executes an agent run and streams the resulting events using Server-Sent Events (SSE).
	 *
	 * @param request The AgentRunRequest containing run details.
	 * @return A Flux that will stream events to the client in standard SSE format.
	 */
	@PostMapping(value = "/run_sse", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
	public Flux<ServerSentEvent<String>> agentRunSse(@RequestBody AgentRunRequest request) {
		if (request.appName == null || request.appName.trim().isEmpty()) {
			log.warn(
					"appName cannot be null or empty in SSE request for appName: {}, session: {}",
					request.appName,
					request.threadId);
			return Flux.error(
					new ResponseStatusException(HttpStatus.BAD_REQUEST, "appName cannot be null or empty"));
		}
		if (request.threadId == null || request.threadId.trim().isEmpty()) {
			log.warn(
					"threadId cannot be null or empty in SSE request for appName: {}, session: {}",
					request.appName,
					request.threadId);
			return Flux.error(
					new ResponseStatusException(HttpStatus.BAD_REQUEST, "threadId cannot be null or empty"));
		}

		try {
			Agent agent = agentLoader.loadAgent(request.appName);
			RunnableConfig runnableConfig = RunnableConfig.builder()
					.threadId(request.threadId)
					.addMetadata("user_id", request.userId)
					.build();

			return executeAgent(request.newMessage.toUserMessage(), agent, runnableConfig);

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Set appName in the request body to the exact registered app name shown in Studio.
  2. Trim/validate the value client-side before sending; treat empty strings as missing.
  3. Check the JSON field name matches what the request record expects (appName).
  4. If the app was renamed or deleted, refresh the app list and use the current name.

Example fix

// before
curl -N -X POST /execution/run -d '{"threadId":"t1"}'
// after
curl -N -X POST /execution/run -d '{"appName":"my-app","threadId":"t1"}'
Defensive patterns

Strategy: validation

Validate before calling

if (appName == null || appName.isBlank()) throw new IllegalArgumentException("appName is required");

Try / catch

webClient.post().uri("/execution/run").bodyValue(req).retrieve()
  .onStatus(status -> status.value() == 400, resp -> Mono.error(new IllegalArgumentException("appName missing/blank in run request")))
  .bodyToFlux(String.class);

Prevention

When it happens

Trigger: POSTing to the studio SSE run endpoint with a request body missing appName, an empty string, or whitespace-only value; client code serializing a request object with an unset appName field.

Common situations: Frontend not filling the app selector before submitting, renamed app not updated in the client, hand-written curl/test payloads omitting the field, case mismatch in JSON field names.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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