{"record":{"id":"3293649f9dfd9696","repo":"spring-projects/spring-ai","slug":"delete-operation-failed-329364","errorCode":null,"errorMessage":"Delete operation failed","messagePattern":"Delete operation failed","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"vector-stores/spring-ai-opensearch-store/src/main/java/org/springframework/ai/vectorstore/opensearch/OpenSearchVectorStore.java","lineNumber":262,"sourceCode":"\t\t\t\t\t.operations(op -> op.index(idx -> idx.index(this.index).document(openSearchDocument)));\n\t\t\t}\n\t\t}\n\t\tbulkRequest(bulkRequestBuilder.build());\n\t}\n\n\t@Override\n\tpublic void doDelete(List<String> idList) {\n\t\tif (!this.manageDocumentIds) {\n\t\t\tlogger.warn(\"Document ID management is disabled. Delete operations may not work as expected \"\n\t\t\t\t\t+ \"since document IDs are auto-generated by OpenSearch. Consider using filter-based deletion instead.\");\n\t\t}\n\n\t\tBulkRequest.Builder bulkRequestBuilder = new BulkRequest.Builder();\n\t\tfor (String id : idList) {\n\t\t\tbulkRequestBuilder.operations(op -> op.delete(idx -> idx.index(this.index).id(id)));\n\t\t}\n\t\tif (bulkRequest(bulkRequestBuilder.build()).errors()) {\n\t\t\tthrow new IllegalStateException(\"Delete operation failed\");\n\t\t}\n\t}\n\n\tprivate BulkResponse bulkRequest(BulkRequest bulkRequest) {\n\t\ttry {\n\t\t\treturn this.openSearchClient.bulk(bulkRequest);\n\t\t}\n\t\tcatch (IOException e) {\n\t\t\tthrow new RuntimeException(e);\n\t\t}\n\t}\n\n\t@Override\n\tprotected void doDelete(Filter.Expression filterExpression) {\n\t\tAssert.notNull(filterExpression, \"Filter expression must not be null\");\n\n\t\ttry {\n\t\t\tString filterStr = this.filterExpressionConverter.convertExpression(filterExpression);","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/vector-stores/spring-ai-opensearch-store/src/main/java/org/springframework/ai/vectorstore/opensearch/OpenSearchVectorStore.java#L244-L280","documentation":"OpenSearchVectorStore.doDelete builds a BulkRequest of delete operations; if the returned BulkResponse reports errors=true, it throws IllegalStateException('Delete operation failed'). The individual per-item failure details are in the BulkResponse, which this throw does not attach, so you must inspect the bulk response or logs for specifics.","triggerScenarios":"Calling vectorStore.delete(List<String> ids) where at least one bulk delete item fails on the OpenSearch cluster (e.g. document missing under strict mapping, index issues, cluster connectivity problems that still yield a response).","commonSituations":"Deleting documents by ids that were already removed or never indexed while the index uses external versioning/strict settings; OpenSearch cluster returning partial failures; index read-only due to disk watermark exceeded.","solutions":["Enable debug logging or capture the BulkResponse items to see which ids failed and why.","Check the OpenSearch cluster health and disk watermarks (read-only index blocks cause delete failures).","Verify the ids exist in the target index before deleting, or ignore 404-style item failures.","Retry the delete for the failed subset of ids."],"exampleFix":"// before\nvectorStore.delete(ids); // opaque failure\n// after\ntry {\n    vectorStore.delete(ids);\n} catch (IllegalStateException e) {\n    // inspect cluster: GET /_cluster/health and per-item bulk errors\n    ids.forEach(id -> indexOps.exists(id)); // confirm which docs are missing\n}","handlingStrategy":"retry","validationCode":"// ensure cluster is writable before bulk delete\nboolean writable = client.cluster().health().status() == Status.GREEN\n    || client.cluster().health().status() == Status.YELLOW;","typeGuard":null,"tryCatchPattern":"try {\n    vectorStore.delete(ids);\n} catch (IllegalStateException e) {\n    // inspect cluster/bulk item errors, then retry the failed subset\n    retryDelete(ids);\n}","preventionTips":["Monitor OpenSearch disk watermarks (read-only index blocks delete)","Check cluster health before bulk operations","Treat missing ids as expected and handle partial failures","Log bulk item-level failures for diagnosis"],"tags":["opensearch","vector-store","delete","bulk-request"],"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-14T11:17:12.474Z"}