{"record":{"id":"da5aa93b15327679","repo":"alibaba/spring-ai-alibaba","slug":"graphname-cannot-be-null-or-empty-da5aa9","errorCode":null,"errorMessage":"graphName cannot be null or empty","messagePattern":"graphName cannot be null or empty","errorType":"http","errorClass":"ResponseStatusException","httpStatus":400,"severity":"warning","filePath":"spring-ai-alibaba-studio/src/main/java/com/alibaba/cloud/ai/agent/studio/controller/GraphThreadController.java","lineNumber":76,"sourceCode":"\tprivate static final String EVAL_SESSION_ID_PREFIX = \"SAA_EVAL_\";\n\n\tprivate final GraphLoader graphLoader;\n\n\tprivate final ThreadService threadService;\n\n\t@Autowired\n\tpublic GraphThreadController(GraphLoader graphLoader, ThreadService threadService) {\n\t\tthis.graphLoader = graphLoader;\n\t\tthis.threadService = threadService;\n\t}\n\n\tprivate String toAppName(String graphName) {\n\t\treturn GRAPH_APP_PREFIX + graphName;\n\t}\n\n\tprivate void validateGraphExists(String graphName) {\n\t\tif (graphName == null || graphName.isBlank()) {\n\t\t\tthrow new ResponseStatusException(HttpStatus.BAD_REQUEST, \"graphName cannot be null or empty\");\n\t\t}\n\t\tif (!graphLoader.listGraphs().contains(graphName)) {\n\t\t\tthrow new ResponseStatusException(HttpStatus.NOT_FOUND, \"Graph not found: \" + graphName);\n\t\t}\n\t}\n\n\tprivate Thread findThreadOrThrow(String graphName, String userId, String threadId) {\n\t\tString appName = toAppName(graphName);\n\t\tOptional<Thread> optionalThread =\n\t\t\t\tthreadService.getThread(appName, userId, threadId, Optional.empty()).block();\n\n\t\tif (optionalThread == null || !optionalThread.isPresent()) {\n\t\t\tthrow new ResponseStatusException(HttpStatus.NOT_FOUND,\n\t\t\t\t\tString.format(\"Thread not found: graphName=%s, userId=%s, threadId=%s\",\n\t\t\t\t\t\t\tgraphName, userId, threadId));\n\t\t}\n\n\t\tThread thread = optionalThread.get();","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-studio/src/main/java/com/alibaba/cloud/ai/agent/studio/controller/GraphThreadController.java#L58-L94","documentation":"GraphThreadController.validateGraphExists first rejects a null/blank graphName with a 400 BAD_REQUEST ResponseStatusException before checking graph existence. It is called by all thread endpoints (getThread, listThreads, createThreadWithId, createThread, deleteThread).","triggerScenarios":"Any thread API call under /graphs/{graphName}/users/... with an empty or whitespace-only graphName path segment.","commonSituations":"Client building URLs from an unset variable; URL-encoded blank segments; misconfigured frontend router passing empty params.","solutions":["Supply a valid non-blank graph name in the request path.","Validate graphName client-side before issuing the request.","Verify router/path parameter bindings aren't dropping the value."],"exampleFix":"// before\nconst url = `/graphs/${graphName}/users/${userId}/threads`;\n// after\nif (!graphName || !graphName.trim()) return Promise.reject('graphName required');\nconst url = `/graphs/${encodeURIComponent(graphName)}/users/${userId}/threads`;","handlingStrategy":"validation","validationCode":"// client-side guard before any thread API call\nif (!graphName || !graphName.trim()) {\n  throw new Error('graphName is required for thread APIs');\n}","typeGuard":"function isValidGraphParam(name) {\n  return typeof name === 'string' && name.trim().length > 0;\n}","tryCatchPattern":"try {\n  await api.get(`/graphs/${graphName}/users/${userId}/threads`);\n} catch (e) {\n  if (e.response?.status === 400) { /* blank graphName - fix request */ }\n}","preventionTips":["Default/fallback graphName in client config.","Validate path params before URL construction.","Avoid building URLs from possibly-unset variables."],"tags":["http-400","rest","validation"],"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-17T15:17:12.973Z"}