{"record":{"id":"e0d7a617d2677e68","repo":"alibaba/spring-ai-alibaba","slug":"name-must-be-provided-e0d7a6","errorCode":null,"errorMessage":"Name must be provided","messagePattern":"Name must be provided","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/flow/builder/FlowAgentBuilder.java","lineNumber":177,"sourceCode":"\t\tthis.hooks.addAll(hooks);\n\t\treturn self();\n\t}\n\n\t/**\n\t * Returns the concrete builder instance. This method enables fluent interface support\n\t * in subclasses.\n\t * @return this builder instance\n\t */\n\tprotected abstract B self();\n\n\t/**\n\t * Validates the builder state before creating the agent. Subclasses can override this\n\t * method to add specific validation logic.\n\t * @throws IllegalArgumentException if validation fails\n\t */\n\tprotected void validate() {\n\t\tif (name == null || name.trim().isEmpty()) {\n\t\t\tthrow new IllegalArgumentException(\"Name must be provided\");\n\t\t}\n\t\tif (subAgents == null || subAgents.isEmpty()) {\n\t\t\tthrow new IllegalArgumentException(\"At least one sub-agent must be provided for flow\");\n\t\t}\n\t}\n\n\t/**\n\t * Builds the concrete FlowAgent instance. Subclasses must implement this method to\n\t * create the specific agent type.\n\t * @return the built FlowAgent instance\n\t * @throws GraphStateException if agent creation fails\n\t */\n\tpublic T build() {\n\t\tif (this.saver != null) {\n\t\t\tif (this.compileConfig == null) {\n\t\t\t\tthis.compileConfig = CompileConfig.builder().saverConfig(SaverConfig.builder().register(saver).build()).build();\n\t\t\t}\n\t\t\tthis.compileConfig = CompileConfig.builder(compileConfig).saverConfig(SaverConfig.builder().register(saver).build()).build();","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/flow/builder/FlowAgentBuilder.java#L159-L195","documentation":"FlowAgentBuilder.validate() throws when the builder name is null or blank before any flow agent (sequential, parallel, routing, etc.) is created. The name identifies the agent node in the graph and is mandatory for all flow agents.","triggerScenarios":"Calling any FlowAgentBuilder subclass's build() without .name(...), or with a whitespace-only name.","commonSituations":"Name supplied from a nullable config value; builder assembled dynamically and the name setter skipped; migration from an API version where name was optional.","solutions":["Call .name(\"<agent-name>\") before .build()","Check that the config/property feeding the name is set and non-blank","Validate/trim the name string before passing it to the builder"],"exampleFix":"// before\nSequentialAgent.builder().subAgents(a, b).build();\n// after\nSequentialAgent.builder().name(\"pipeline\").subAgents(a, b).build();","handlingStrategy":"validation","validationCode":"if (name == null || name.trim().isEmpty()) throw new IllegalArgumentException(\"Flow agent name required\");","typeGuard":"boolean nonBlank(String s) { return s != null && !s.isBlank(); }","tryCatchPattern":"try { agent = builder.build(); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"Name must be provided\")) { /* supply name and rebuild */ } else throw e; }","preventionTips":["Set .name(...) first in every flow builder chain","Back agent names with validated config","Test-build all flow agents in CI"],"tags":["validation","builder","missing-name"],"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-14T11:17:12.474Z"}