{"record":{"id":"2641ece8cb6af091","repo":"spring-projects/spring-ai","slug":"either-prompt-or-uri-must-be-provided-2641ec","errorCode":null,"errorMessage":"Either prompt or uri must be provided","messagePattern":"Either prompt or uri must be provided","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"mcp/mcp-annotations/src/main/java/org/springframework/ai/mcp/annotation/method/complete/AbstractMcpCompleteMethodCallback.java","lineNumber":491,"sourceCode":"\t\t@SuppressWarnings(\"unchecked\")\n\t\tpublic T uriTemplateManagerFactory(McpUriTemplateManagerFactory uriTemplateManagerFactory) {\n\t\t\tthis.uriTemplateManagerFactory = uriTemplateManagerFactory;\n\t\t\treturn (T) this;\n\t\t}\n\n\t\t/**\n\t\t * Validate the builder state.\n\t\t * @throws IllegalArgumentException if the builder state is invalid\n\t\t */\n\t\tprotected void validate() {\n\t\t\tif (this.method == null) {\n\t\t\t\tthrow new IllegalArgumentException(\"Method must not be null\");\n\t\t\t}\n\t\t\tif (this.bean == null) {\n\t\t\t\tthrow new IllegalArgumentException(\"Bean must not be null\");\n\t\t\t}\n\t\t\tif ((this.prompt == null || this.prompt.isEmpty()) && (this.uri == null || this.uri.isEmpty())) {\n\t\t\t\tthrow new IllegalArgumentException(\"Either prompt or uri must be provided\");\n\t\t\t}\n\t\t\tif ((this.prompt != null && !this.prompt.isEmpty()) && (this.uri != null && !this.uri.isEmpty())) {\n\t\t\t\tthrow new IllegalArgumentException(\"Only one of prompt or uri can be provided\");\n\t\t\t}\n\t\t\tif (this.uriTemplateManagerFactory == null) {\n\t\t\t\tthis.uriTemplateManagerFactory = new DefaultMcpUriTemplateManagerFactory();\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Build the callback.\n\t\t * @return A new callback instance\n\t\t */\n\t\tpublic abstract R build();\n\n\t}\n\n}","sourceCodeStart":473,"sourceCodeEnd":509,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/mcp/mcp-annotations/src/main/java/org/springframework/ai/mcp/annotation/method/complete/AbstractMcpCompleteMethodCallback.java#L473-L509","documentation":"Builder-state validation in AbstractMcpCompleteMethodCallback.Builder.validate: a completion callback was registered with neither a prompt reference nor a URI, so there is no completion target to bind the annotated method to.","triggerScenarios":"Thrown at mcp/mcp-annotations/src/main/java/org/springframework/ai/mcp/annotation/method/complete/AbstractMcpCompleteMethodCallback.java:491 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set prompt(...) on the builder for prompt-completion methods","Set uri(...) on the builder for resource-completion methods"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}