{"record":{"id":"10ca73441e58480e","repo":"alibaba/spring-ai-alibaba","slug":"searchrequest-cannot-be-null","errorCode":null,"errorMessage":"searchRequest cannot be null","messagePattern":"searchRequest cannot be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/store/stores/BaseStore.java","lineNumber":100,"sourceCode":"\tprotected void validateDeleteItem(List<String> namespace, String key) {\n\t\tif (namespace == null) {\n\t\t\tthrow new IllegalArgumentException(\"namespace cannot be null\");\n\t\t}\n\t\tif (key == null) {\n\t\t\tthrow new IllegalArgumentException(\"key cannot be null\");\n\t\t}\n\t\tif (key.trim().isEmpty()) {\n\t\t\tthrow new IllegalArgumentException(\"key cannot be empty\");\n\t\t}\n\t}\n\n\t/**\n\t * Validates the searchItems parameters.\n\t * @param searchRequest search request\n\t */\n\tprotected void validateSearchItems(StoreSearchRequest searchRequest) {\n\t\tif (searchRequest == null) {\n\t\t\tthrow new IllegalArgumentException(\"searchRequest cannot be null\");\n\t\t}\n\t}\n\n\t/**\n\t * Validates the listNamespaces parameters.\n\t * @param namespaceRequest namespace request\n\t */\n\tprotected void validateListNamespaces(NamespaceListRequest namespaceRequest) {\n\t\tif (namespaceRequest == null) {\n\t\t\tthrow new IllegalArgumentException(\"namespaceRequest cannot be null\");\n\t\t}\n\t}\n\n\t/**\n\t * Create store key from namespace and key Uses safe encoding to avoid conflicts from\n\t * special characters.\n\t * @param namespace namespace\n\t * @param key key","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/store/stores/BaseStore.java#L82-L118","documentation":"BaseStore.validateSearchItems requires a non-null StoreSearchRequest. Search parameters (query, limit, filters) are carried in this request object; passing null leaves the search undefined, so the library throws IllegalArgumentException before executing any query.","triggerScenarios":"Calling store.searchItems(null) directly, or passing a request variable that failed to build (e.g. optional request object left uninitialized).","commonSituations":"Conditional request construction where the build method returns null on some code path; reflective/deserialized controllers binding null bodies; tests passing null expecting defaults.","solutions":["Always construct a StoreSearchRequest, even for unrestricted searches (empty query/default limit).","Null-check or use Objects.requireNonNullElse(request, defaultRequest) before calling searchItems.","Catch IllegalArgumentException if the request comes from an optional input and substitute a default."],"exampleFix":"// before\nvar results = store.searchItems(maybeRequest);\n// after\nStoreSearchRequest req = maybeRequest != null ? maybeRequest\n        : StoreSearchRequest.builder().limit(10).build();\nvar results = store.searchItems(req);","handlingStrategy":"validation","validationCode":"if (request == null) {\n    request = StoreSearchRequest.builder().limit(10).build();\n}\nstore.searchItems(request);","typeGuard":"StoreSearchRequest orDefault(StoreSearchRequest r) { return r != null ? r : StoreSearchRequest.builder().limit(10).build(); }","tryCatchPattern":"try {\n    store.searchItems(request);\n} catch (IllegalArgumentException e) {\n    store.searchItems(StoreSearchRequest.builder().limit(10).build());\n}","preventionTips":["Always build a request object even for broad searches.","Use Objects.requireNonNullElse for optional request DTOs.","Initialize builder fields with defaults so builders never yield null."],"tags":["java","validation","null-argument","store"],"backgroundTag":"null-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"}