{"record":{"id":"88280499a2d912d0","repo":"spring-projects/spring-ai","slug":"failed-to-delete-some-documents-882804","errorCode":null,"errorMessage":"Failed to delete some documents","messagePattern":"Failed to delete some documents","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"vector-stores/spring-ai-redis-store/src/main/java/org/springframework/ai/vectorstore/redis/RedisVectorStore.java","lineNumber":440,"sourceCode":"\t\t\t\tif (docs == null || docs.isEmpty()) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\ttry (Pipeline pipeline = this.jedisClient.pipelined()) {\n\t\t\t\t\tfor (redis.clients.jedis.search.Document doc : docs) {\n\t\t\t\t\t\tString redisKey = doc.getId();\n\t\t\t\t\t\tString id = redisKey.startsWith(this.prefix) ? redisKey.substring(this.prefix.length())\n\t\t\t\t\t\t\t\t: redisKey;\n\t\t\t\t\t\tpipeline.jsonDel(key(id));\n\t\t\t\t\t}\n\t\t\t\t\tList<Object> responses = pipeline.syncAndReturnAll();\n\t\t\t\t\tOptional<Object> errResponse = responses.stream().filter(Predicate.not(RESPONSE_DEL_OK)).findAny();\n\n\t\t\t\t\tif (errResponse.isPresent()) {\n\t\t\t\t\t\tif (logger.isErrorEnabled()) {\n\t\t\t\t\t\t\tlogger.error(\"Could not delete document: \" + errResponse.get());\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow new IllegalStateException(\"Failed to delete some documents\");\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tdeletedCount += docs.size();\n\t\t\t}\n\n\t\t\tif (logger.isDebugEnabled()) {\n\t\t\t\tlogger.debug(\"Deleted \" + deletedCount + \" documents matching filter expression\");\n\t\t\t}\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tlogger.error(\"Failed to delete documents by filter\", e);\n\t\t\tthrow new IllegalStateException(\"Failed to delete documents by filter\", e);\n\t\t}\n\t}\n\n\t@Override\n\tpublic List<Document> doSimilaritySearch(SearchRequest request) {","sourceCodeStart":422,"sourceCodeEnd":458,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/vector-stores/spring-ai-redis-store/src/main/java/org/springframework/ai/vectorstore/redis/RedisVectorStore.java#L422-L458","documentation":"RedisVectorStore.doDelete() deletes documents by key in a pipeline and verifies each reply equals the expected deletion count (RESPONSE_DEL_OK). If any reply differs, it logs the offending response and throws an IllegalStateException meaning some documents were not deleted. A common cause is a key that no longer exists (DEL returns 0).","triggerScenarios":"Calling vectorStore.delete(List.of(id)) where at least one id has no corresponding key in Redis (already deleted, wrong prefix configured, or TTL expired), so DEL replies 0 instead of 1.","commonSituations":"Deleting the same document ids twice; store configured with a different key prefix than the one used at write time; expired keys (TTL set); id casing or whitespace mismatches.","solutions":["Verify the ids passed to delete() exist (e.g. check via getKey/FT.SEARCH) before deleting","Ensure the store's key prefix matches the one used when documents were added","Treat re-deletion of unknown ids defensively: filter ids to existing keys first","Check for TTL/eviction settings in Redis that may have removed the keys"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Only delete ids that exist\nList<String> existing = ids.stream().filter(id -> jedisClient.exists(storePrefix + id)).toList();\nstore.delete(existing);","typeGuard":null,"tryCatchPattern":"try { store.delete(ids); } catch (IllegalStateException e) { if (e.getMessage().equals(\"Failed to delete some documents\")) { /* check prefix/TTL, skip missing ids */ } }","preventionTips":["Keep the key prefix identical between add and delete paths","Don't re-delete already-deleted ids; track deletion state","Watch for TTL/eviction policies removing keys early"],"tags":["redis","vector-store","delete","key-not-found"],"backgroundTag":"database-write-failed","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}