{"record":{"id":"742e24470d2ff1b8","repo":"alibaba/spring-ai-alibaba","slug":"failed-to-retrieve-item-from-redis-like-storage","errorCode":null,"errorMessage":"Failed to retrieve item from Redis-like storage","messagePattern":"Failed to retrieve item from Redis-like storage","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/store/stores/RedisStore.java","lineNumber":111,"sourceCode":"\n\t@Override\n\tpublic Optional<StoreItem> getItem(List<String> namespace, String key) {\n\t\tvalidateGetItem(namespace, key);\n\n\t\tlock.readLock().lock();\n\t\ttry {\n\t\t\tString redisKey = createRedisKey(namespace, key);\n\t\t\tString value = redisLikeStorage.get(redisKey);\n\n\t\t\tif (value == null) {\n\t\t\t\treturn Optional.empty();\n\t\t\t}\n\n\t\t\tStoreItem item = objectMapper.readValue(value, StoreItem.class);\n\t\t\treturn Optional.of(item);\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tthrow new RuntimeException(\"Failed to retrieve item from Redis-like storage\", e);\n\t\t}\n\t\tfinally {\n\t\t\tlock.readLock().unlock();\n\t\t}\n\t}\n\n\t@Override\n\tpublic boolean deleteItem(List<String> namespace, String key) {\n\t\tvalidateDeleteItem(namespace, key);\n\n\t\tlock.writeLock().lock();\n\t\ttry {\n\t\t\tString redisKey = createRedisKey(namespace, key);\n\t\t\treturn redisLikeStorage.remove(redisKey) != null;\n\t\t}\n\t\tfinally {\n\t\t\tlock.writeLock().unlock();\n\t\t}","sourceCodeStart":93,"sourceCodeEnd":129,"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/RedisStore.java#L93-L129","documentation":"RedisStore.getItem reads the JSON value for a namespace-qualified key and deserializes it back into a StoreItem. Failures reading from storage or deserializing the payload are wrapped in this RuntimeException, and the read lock is always released in a finally block.","triggerScenarios":"Calling RedisStore.getItem(...) when the storage read fails (connection issue) or the stored bytes cannot be deserialized into StoreItem (corrupted or schema-mismatched JSON, e.g. written by an older version of the class).","commonSituations":"Redis unavailable, stored payload changed shape after a StoreItem field/type change or library upgrade, manually edited Redis data, or ObjectMapper deserialization config mismatch.","solutions":["Inspect e.getCause(): if it is a JsonProcessingException/JsonParseException the stored payload no longer matches StoreItem — migrate or delete the stale key.","Verify Redis connectivity and credentials if the cause is a connection exception.","Re-write the item with putItem from the current library version to refresh the payload format.","Ensure the same ObjectMapper configuration is used for read and write."],"exampleFix":"// before\nStoreItem item = store.getItem(namespace, key).orElse(null); // may throw on legacy JSON\n// after\nStoreItem item;\ntry {\n    item = store.getItem(namespace, key).orElse(null);\n} catch (RuntimeException e) {\n    logger.warn(\"getItem failed, treating as missing\", e.getCause());\n    item = null;\n}","handlingStrategy":"try-catch","validationCode":"// no pre-call validation possible for stored payload; optionally check existence first\nOptional<String> value = rawGet(key); // if the client exposes it, validate JSON before deserializing","typeGuard":null,"tryCatchPattern":"try {\n    return store.getItem(ns, key);\n} catch (RuntimeException e) {\n    if (e.getCause() instanceof JsonProcessingException) {\n        logger.warn(\"Corrupt/legacy payload for {}:{} — treating as absent\", ns, key);\n        return Optional.empty();\n    }\n    throw e;\n}","preventionTips":["Keep StoreItem schema stable; bump namespace prefix on incompatible changes.","Migrate old payloads after upgrades.","Monitor Redis connectivity separately.","Never hand-edit stored JSON."],"tags":["redis","storage","deserialization"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}