{"record":{"id":"c8dadf9d562ed3c3","repo":"alibaba/spring-ai-alibaba","slug":"graph-name-cannot-be-null-or-empty","errorCode":null,"errorMessage":"Graph name cannot be null or empty","messagePattern":"Graph name cannot be null or empty","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-studio/src/main/java/com/alibaba/cloud/ai/agent/studio/loader/AbstractGraphLoader.java","lineNumber":94,"sourceCode":"\t\t\t}\n\t\t\tif (result.putIfAbsent(graphName, graph) != null) {\n\t\t\t\tlog.warn(\"Duplicate graph name '{}', keeping first. Consider using unique graph names for Studio.\",\n\t\t\t\t\t\tgraphName);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\t@Override\n\t@Nonnull\n\tpublic List<String> listGraphs() {\n\t\treturn List.copyOf(getGraphMap().keySet());\n\t}\n\n\t@Override\n\tpublic CompiledGraph loadGraph(String name) {\n\t\tif (name == null || name.trim().isEmpty()) {\n\t\t\tthrow new IllegalArgumentException(\"Graph name cannot be null or empty\");\n\t\t}\n\t\tCompiledGraph graph = getGraphMap().get(name);\n\t\tif (graph == null) {\n\t\t\tthrow new NoSuchElementException(\"Graph not found: \" + name);\n\t\t}\n\t\treturn graph;\n\t}\n}\n","sourceCodeStart":76,"sourceCodeEnd":103,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-studio/src/main/java/com/alibaba/cloud/ai/agent/studio/loader/AbstractGraphLoader.java#L76-L103","documentation":"AbstractGraphLoader.loadGraph(String name) throws IllegalArgumentException when the graph name argument is null, empty, or whitespace-only. This is an argument validation guard executed before any map lookup. It protects the graph map from meaningless keys and gives a clear message instead of a confusing lookup miss.","triggerScenarios":"Calling loadGraph(null), loadGraph(\"\"), or loadGraph(\"   \") — typically when the name comes from an unset config property, an empty request parameter, or an uninitialized variable.","commonSituations":"Missing Spring property (e.g. ${graph.name} unresolved or empty); request JSON omitting the graphName field; variable not populated after failed parsing of a request payload.","solutions":["Ensure the caller passes a non-blank graph name; trim and check for emptiness before calling loadGraph","If the name comes from configuration, set the property or provide a default value","If the name comes from an HTTP request, make the field required and validate it at the controller boundary"],"exampleFix":"// before\nCompiledGraph graph = loader.loadGraph(config.getGraphName()); // may be null/empty\n// after\nString name = config.getGraphName();\nif (name == null || name.isBlank()) {\n    throw new IllegalArgumentException(\"graphName must be configured\");\n}\nCompiledGraph graph = loader.loadGraph(name.trim());","handlingStrategy":"validation","validationCode":"if (graphName == null || graphName.isBlank()) {\n    throw new IllegalArgumentException(\"graphName is required and must not be blank\");\n}","typeGuard":"static boolean hasText(String s) { return s != null && !s.isBlank(); }","tryCatchPattern":"try {\n    return loader.loadGraph(graphName);\n} catch (IllegalArgumentException e) {\n    return ResponseEntity.badRequest().body(\"graphName is required\");\n}","preventionTips":["Make graphName a required field in request DTOs (@NotBlank) so validation runs before the loader","Provide default values for graph-name config properties","Never call loadGraph with values derived from possibly-unset environment/config lookups without a null check"],"tags":["java","illegal-argument","null-or-empty","input-validation"],"backgroundTag":"missing-required-argument","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"}