{"record":{"id":"fc993ce087f35a63","repo":"alibaba/spring-ai-alibaba","slug":"appname-cannot-be-null-or-empty","errorCode":null,"errorMessage":"appName cannot be null or empty","messagePattern":"appName cannot be null or empty","errorType":"http","errorClass":"ResponseStatusException","httpStatus":400,"severity":"error","filePath":"spring-ai-alibaba-studio/src/main/java/com/alibaba/cloud/ai/agent/studio/controller/ExecutionController.java","lineNumber":163,"sourceCode":"//\t\t\treturn Flux.error(new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, \"Agent run failed\", e));\n//\t\t}\n//\t}\n\n\t/**\n\t * Executes an agent run and streams the resulting events using Server-Sent Events (SSE).\n\t *\n\t * @param request The AgentRunRequest containing run details.\n\t * @return A Flux that will stream events to the client in standard SSE format.\n\t */\n\t@PostMapping(value = \"/run_sse\", produces = MediaType.TEXT_EVENT_STREAM_VALUE)\n\tpublic Flux<ServerSentEvent<String>> agentRunSse(@RequestBody AgentRunRequest request) {\n\t\tif (request.appName == null || request.appName.trim().isEmpty()) {\n\t\t\tlog.warn(\n\t\t\t\t\t\"appName cannot be null or empty in SSE request for appName: {}, session: {}\",\n\t\t\t\t\trequest.appName,\n\t\t\t\t\trequest.threadId);\n\t\t\treturn Flux.error(\n\t\t\t\t\tnew ResponseStatusException(HttpStatus.BAD_REQUEST, \"appName cannot be null or empty\"));\n\t\t}\n\t\tif (request.threadId == null || request.threadId.trim().isEmpty()) {\n\t\t\tlog.warn(\n\t\t\t\t\t\"threadId cannot be null or empty in SSE request for appName: {}, session: {}\",\n\t\t\t\t\trequest.appName,\n\t\t\t\t\trequest.threadId);\n\t\t\treturn Flux.error(\n\t\t\t\t\tnew ResponseStatusException(HttpStatus.BAD_REQUEST, \"threadId cannot be null or empty\"));\n\t\t}\n\n\t\ttry {\n\t\t\tAgent agent = agentLoader.loadAgent(request.appName);\n\t\t\tRunnableConfig runnableConfig = RunnableConfig.builder()\n\t\t\t\t\t.threadId(request.threadId)\n\t\t\t\t\t.addMetadata(\"user_id\", request.userId)\n\t\t\t\t\t.build();\n\n\t\t\treturn executeAgent(request.newMessage.toUserMessage(), agent, runnableConfig);","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-studio/src/main/java/com/alibaba/cloud/ai/agent/studio/controller/ExecutionController.java#L145-L181","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set appName in the request body to the exact registered app name shown in Studio.","Trim/validate the value client-side before sending; treat empty strings as missing.","Check the JSON field name matches what the request record expects (appName).","If the app was renamed or deleted, refresh the app list and use the current name."],"exampleFix":"// before\ncurl -N -X POST /execution/run -d '{\"threadId\":\"t1\"}'\n// after\ncurl -N -X POST /execution/run -d '{\"appName\":\"my-app\",\"threadId\":\"t1\"}'","handlingStrategy":"validation","validationCode":"if (appName == null || appName.isBlank()) throw new IllegalArgumentException(\"appName is required\");","typeGuard":null,"tryCatchPattern":"webClient.post().uri(\"/execution/run\").bodyValue(req).retrieve()\n  .onStatus(status -> status.value() == 400, resp -> Mono.error(new IllegalArgumentException(\"appName missing/blank in run request\")))\n  .bodyToFlux(String.class);","preventionTips":["Validate request DTOs (appName, threadId non-blank) before sending SSE run requests.","Bind UI submits to a selected app so appName can never be unset.","Refresh app lists after renames/deletes and use exact registered names."],"tags":["http","validation","sse","bad-request"],"backgroundTag":"empty-required-field","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"}