{"record":{"id":"4564249350de58a3","repo":"alibaba/spring-ai-alibaba","slug":"name-must-be-provided","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/a2a/A2aRemoteAgent.java","lineNumber":217,"sourceCode":"\t\tpublic Builder compileConfig(CompileConfig compileConfig) {\n\t\t\tthis.compileConfig = compileConfig;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic Builder streaming(boolean streaming) {\n\t\t\tthis.streaming = streaming;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic Builder shareState(boolean shareState) {\n\t\t\tthis.shareState = shareState;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic A2aRemoteAgent build() {\n\t\t\t// Validation\n\t\t\tif (name == null || name.trim().isEmpty()) {\n\t\t\t\tthrow new IllegalArgumentException(\"Name must be provided\");\n\t\t\t}\n\t\t\tif (description == null || description.trim().isEmpty()) {\n\t\t\t\tthrow new IllegalArgumentException(\"Description must be provided\");\n\t\t\t}\n\t\t\tif (agentCard == null) {\n\t\t\t\tif (null == agentCardProvider) {\n\t\t\t\t\tthrow new IllegalArgumentException(\"AgentCard or AgentCardProvider must be provided\");\n\t\t\t\t}\n\t\t\t\tif (agentCardProvider.supportGetAgentCardByName()) {\n\t\t\t\t\tagentCard = agentCardProvider.getAgentCard(name);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tagentCard = agentCardProvider.getAgentCard();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.streaming = agentCard.capabilities().streaming();\n","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/a2a/A2aRemoteAgent.java#L199-L235","documentation":"A2aRemoteAgent.Builder.build() validates that a non-blank name was set before constructing the agent; a remote A2A agent must have a name so it can be addressed and, when using an AgentCardProvider that resolves by name, matched to its AgentCard. This is a fail-fast IllegalArgumentException at construction time.","triggerScenarios":"Calling A2aRemoteAgent.builder().build() without calling .name(...), or with .name(\"\") or a whitespace-only string.","commonSituations":"Building agents programmatically from config where the name field is missing/empty; copy-pasting a builder snippet and forgetting the name() call; a null property loaded from application config.","solutions":["Set a name: A2aRemoteAgent.builder().name(\"my-remote-agent\").description(\"...\")...build().","Validate the config value is non-blank before invoking the builder.","Default to a sensible name derived from context (e.g. the target service id) when the input is blank."],"exampleFix":"// before\nA2aRemoteAgent agent = A2aRemoteAgent.builder()\n    .description(\"Remote agent\")\n    .build(); // IllegalArgumentException\n\n// after\nA2aRemoteAgent agent = A2aRemoteAgent.builder()\n    .name(\"my-remote-agent\")\n    .description(\"Remote agent\")\n    .build();","handlingStrategy":"validation","validationCode":"if (name == null || name.isBlank()) {\n    throw new IllegalArgumentException(\"name must be non-blank before building A2aRemoteAgent\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    A2aRemoteAgent a = builder.build();\n} catch (IllegalArgumentException e) {\n    log.error(\"Builder validation failed: {}\", e.getMessage());\n}","preventionTips":["Always set .name(...) first in the builder chain.","Validate external config values for blankness before mapping to builders.","Add a unit test that builds every configured agent at startup (fail-fast)."],"tags":["builder","validation","a2a"],"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"}