{"record":{"id":"6a348d02a885eb5f","repo":"spring-projects/spring-ai","slug":"at-least-one-client-id-must-be-specified-6a348d","errorCode":null,"errorMessage":"At least one client Id must be specified","messagePattern":"At least one client Id must be specified","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"mcp/mcp-annotations/src/main/java/org/springframework/ai/mcp/annotation/method/changed/prompt/SyncPromptListChangedSpecification.java","lineNumber":31,"sourceCode":" * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage org.springframework.ai.mcp.annotation.method.changed.prompt;\n\nimport java.util.List;\nimport java.util.Objects;\nimport java.util.function.Consumer;\n\nimport io.modelcontextprotocol.spec.McpSchema;\n\npublic record SyncPromptListChangedSpecification(String[] clients,\n\t\tConsumer<List<McpSchema.Prompt>> promptListChangeHandler) {\n\n\tpublic SyncPromptListChangedSpecification {\n\t\tObjects.requireNonNull(clients, \"clients must not be null\");\n\t\tif (clients.length == 0) {\n\t\t\tthrow new IllegalArgumentException(\"At least one client Id must be specified\");\n\t\t}\n\t\tObjects.requireNonNull(promptListChangeHandler, \"promptListChangeHandler must not be null\");\n\t}\n\n}\n","sourceCodeStart":13,"sourceCodeEnd":37,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/mcp/mcp-annotations/src/main/java/org/springframework/ai/mcp/annotation/method/changed/prompt/SyncPromptListChangedSpecification.java#L13-L37","documentation":"IllegalArgumentException thrown in the compact constructor of the SyncPromptListChangedSpecification record when the clients array is non-null but has length 0. Each specification must target at least one MCP client Id for the sync prompt-list-changed handler; an empty array would bind the handler to nothing and is treated as invalid configuration.","triggerScenarios":"new SyncPromptListChangedSpecification(new String[0], consumer) or an empty array produced dynamically from config/properties. The companion checks also require clients != null and handler != null.","commonSituations":"Empty property lists for client Ids; a filter step removing all candidate clients; renaming McpSyncClient beans so the collected Id list no longer matches and effectively ends up empty; scaffolded specs left with placeholder empty arrays.","solutions":["Supply at least one valid client Id, e.g. new SyncPromptListChangedSpecification(new String[]{\"myClient\"}, handler).","Validate configured client Ids are non-empty before constructing the record and raise a clear configuration error.","Ensure the Ids match the names of registered McpSyncClient beans/connections."],"exampleFix":"// before\nnew SyncPromptListChangedSpecification(new String[0], this::onPromptsChanged);\n// after\nnew SyncPromptListChangedSpecification(new String[]{\"client1\"}, this::onPromptsChanged);","handlingStrategy":"validation","validationCode":"if (clients == null || clients.length == 0) {\n    throw new IllegalStateException(\"At least one MCP client Id must be configured for SyncPromptListChangedSpecification\");\n}\nnew SyncPromptListChangedSpecification(clients, handler);","typeGuard":null,"tryCatchPattern":"try {\n    new SyncPromptListChangedSpecification(clients, handler);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"At least one client Id\")) {\n        throw new ConfigurationException(\"Configure at least one MCP client Id for the sync prompt list changed handler\", e);\n    }\n    throw e;\n}","preventionTips":["Check the client Ids array length before constructing the record.","Fail fast on empty config properties at application startup.","Verify Ids against registered McpSyncClient beans after renames."],"tags":["mcp","record-validation","empty-array","configuration"],"backgroundTag":"empty-required-field","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}