alibaba/spring-ai-alibaba · error · IllegalArgumentException
namespaceRequest cannot be null
Error message
namespaceRequest cannot be null
What it means
BaseStore.validateListNamespaces requires a non-null NamespaceListRequest. The request object carries the prefix and paging options for enumerating namespaces; a null value is treated as an invalid argument rather than interpreted as 'list everything'.
Source
Thrown at spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/store/stores/BaseStore.java:110
}
/**
* Validates the searchItems parameters.
* @param searchRequest search request
*/
protected void validateSearchItems(StoreSearchRequest searchRequest) {
if (searchRequest == null) {
throw new IllegalArgumentException("searchRequest cannot be null");
}
}
/**
* Validates the listNamespaces parameters.
* @param namespaceRequest namespace request
*/
protected void validateListNamespaces(NamespaceListRequest namespaceRequest) {
if (namespaceRequest == null) {
throw new IllegalArgumentException("namespaceRequest cannot be null");
}
}
/**
* Create store key from namespace and key Uses safe encoding to avoid conflicts from
* special characters.
* @param namespace namespace
* @param key key
* @return store key
*/
protected String createStoreKey(List<String> namespace, String key) {
try {
Map<String, Object> keyData = new HashMap<>();
keyData.put("namespace", namespace);
keyData.put("key", key);
return Base64.getEncoder().encodeToString(new ObjectMapper().writeValueAsBytes(keyData));
}
catch (Exception e) {View on GitHub (pinned to f82da0b50f)
Solutions
- Pass a NamespaceListRequest instance, using an empty/default one for unrestricted listings.
- Default the parameter with Objects.requireNonNullElse(request, new NamespaceListRequest()).
- Catch IllegalArgumentException where null is a valid client input and map it to a default request.
Example fix
// before store.listNamespaces(req); // req may be null // after NamespaceListRequest safeReq = req != null ? req : new NamespaceListRequest(); store.listNamespaces(safeReq);
Defensive patterns
Strategy: validation
Validate before calling
if (request == null) {
request = new NamespaceListRequest();
}
store.listNamespaces(request); Type guard
NamespaceListRequest orDefault(NamespaceListRequest r) { return r != null ? r : new NamespaceListRequest(); } Try / catch
try {
store.listNamespaces(request);
} catch (IllegalArgumentException e) {
store.listNamespaces(new NamespaceListRequest());
} Prevention
- Default absent request bodies to an empty request object in controllers.
- Document that null does not mean 'list all' for this API.
- Add bean-validation (@NotNull) on request parameters at the entry point.
When it happens
Trigger: Calling store.listNamespaces(null), or passing an uninitialized/failed-to-build NamespaceListRequest.
Common situations: Optional request DTOs bound from HTTP bodies that are absent; builder chains short-circuited by earlier nulls; unit tests passing null expecting default behavior.
Related errors
- key cannot be null
- searchRequest cannot be null
- key cannot be null or empty
- key cannot be empty
- TOOL_PARAMS_MISSING
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/c5f0681990c6074f.
Report an issue: GitHub.