{"record":{"id":"51d8315d79054a9e","repo":"alibaba/spring-ai-alibaba","slug":"namespace-cannot-be-null","errorCode":null,"errorMessage":"namespace cannot be null","messagePattern":"namespace 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":53,"sourceCode":" * This class offers a foundation for implementing the Store interface with consistent\n * validation behavior and common helper methods.\n * </p>\n *\n * @author Spring AI Alibaba\n * @since 1.0.0.3\n */\npublic abstract class BaseStore implements Store {\n\n\t/**\n\t * Validates the putItem parameters.\n\t * @param item the item to validate\n\t */\n\tprotected void validatePutItem(StoreItem item) {\n\t\tif (item == null) {\n\t\t\tthrow new IllegalArgumentException(\"item cannot be null\");\n\t\t}\n\t\tif (item.getNamespace() == null) {\n\t\t\tthrow new IllegalArgumentException(\"namespace cannot be null\");\n\t\t}\n\t\tif (item.getKey() == null || item.getKey().trim().isEmpty()) {\n\t\t\tthrow new IllegalArgumentException(\"key cannot be null or empty\");\n\t\t}\n\t}\n\n\t/**\n\t * Validates the getItem parameters.\n\t * @param namespace namespace\n\t * @param key key\n\t */\n\tprotected void validateGetItem(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}","sourceCodeStart":35,"sourceCodeEnd":71,"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#L35-L71","documentation":"Generic validation guard in BaseStore.validatePutItem, the shared preconditions helper implemented by all Store implementations. A StoreItem must have a namespace to be addressable; when StoreItem.getNamespace() is null the item is malformed for storage and IllegalArgumentException is thrown before any backend write occurs. The same helper also rejects null items and null/blank keys. Callers should construct StoreItem with a non-null namespace.","triggerScenarios":"Creating a StoreItem via a builder/constructor that leaves namespace unset, or constructing the item manually with a null namespace list, then calling store.putItem(item).","commonSituations":"Omitting the namespace when building the item from user/config data; deserializing an item from JSON where the namespace field was absent; a default constructor path that skips namespace.","solutions":["Set a namespace (even empty list semantics per API docs) when building StoreItem","Validate item.getNamespace() != null before putItem","Check deserialization/builder code that drops the namespace field"],"exampleFix":"// before\nStoreItem item = StoreItem.builder().key(\"k\").value(v).build();\nstore.putItem(item);\n// after\nStoreItem item = StoreItem.builder().namespace(List.of(\"users\")).key(\"k\").value(v).build();\nstore.putItem(item);","handlingStrategy":"validation","validationCode":"if (item == null || item.getNamespace() == null) { /* fix before putItem */ }","typeGuard":null,"tryCatchPattern":"try { store.putItem(item); } catch (IllegalArgumentException e) { log.warn(\"namespace missing on item\", e); }","preventionTips":["Always set namespace in StoreItem builders","Validate deserialized items before persisting"],"tags":["java","store","null-check","namespace"],"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"}