{"record":{"id":"78090857ab1d9b82","repo":"spring-projects/spring-ai","slug":"failed-to-delete-documents-because","errorCode":null,"errorMessage":"Failed to delete documents because: \n","messagePattern":"Failed to delete documents because: \n","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"vector-stores/spring-ai-weaviate-store/src/main/java/org/springframework/ai/vectorstore/weaviate/WeaviateVectorStore.java","lineNumber":289,"sourceCode":"\n\t\tResult<BatchDeleteResponse> result = this.weaviateClient.batch()\n\t\t\t.objectsBatchDeleter()\n\t\t\t.withClassName(this.options.getObjectClass())\n\t\t\t.withConsistencyLevel(this.consistencyLevel.name())\n\t\t\t.withWhere(WhereFilter.builder()\n\t\t\t\t.path(\"id\")\n\t\t\t\t.operator(Operator.ContainsAny)\n\t\t\t\t.valueString(documentIds.toArray(new String[0]))\n\t\t\t\t.build())\n\t\t\t.run();\n\n\t\tif (result.hasErrors()) {\n\t\t\tString errorMessages = result.getError()\n\t\t\t\t.getMessages()\n\t\t\t\t.stream()\n\t\t\t\t.map(WeaviateErrorMessage::getMessage)\n\t\t\t\t.collect(Collectors.joining(\",\"));\n\t\t\tthrow new RuntimeException(\"Failed to delete documents because: \\n\" + errorMessages);\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\t// Use similarity search with empty query to find documents matching the\n\t\t\t// filter\n\t\t\tSearchRequest searchRequest = SearchRequest.builder()\n\t\t\t\t.query(\"\") // empty query since we only want filter matches\n\t\t\t\t.filterExpression(filterExpression)\n\t\t\t\t.topK(10000) // large enough to get all matches\n\t\t\t\t.similarityThresholdAll()\n\t\t\t\t.build();\n\n\t\t\tList<Document> matchingDocs = similaritySearch(searchRequest);","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/vector-stores/spring-ai-weaviate-store/src/main/java/org/springframework/ai/vectorstore/weaviate/WeaviateVectorStore.java#L271-L307","documentation":"WeaviateVectorStore.doDelete(List<String> idList) issues a batch delete by document IDs. If the delete response has top-level errors, their joined messages are thrown as a RuntimeException. The delete round-trip itself failed rather than matching zero documents.","triggerScenarios":"VectorStore.delete(List<String>) when the Weaviate batch delete call returns Result.hasErrors() — server unreachable, invalid session/API key, or malformed delete request referencing an unknown class.","commonSituations":"Deleting with IDs from a different store/class; Weaviate restarted with a wiped schema; network interruption between add and delete; wrong API key lacking delete permissions.","solutions":["Check the joined messages after 'because: \\n' in the exception for the underlying Weaviate cause.","Verify the document IDs are valid UUIDs that exist in the configured objectClass.","Confirm server connectivity and credentials as with add failures.","Ensure the Weaviate class name configured on the store matches the one the documents were written to."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// confirm the class exists before deleting\nGET {weaviateUrl}/v1/schema/{className} -> 200 expected; also verify IDs are UUIDs before calling delete","typeGuard":null,"tryCatchPattern":"try { vectorStore.delete(ids); } catch (RuntimeException e) { log.error(\"Weaviate batch delete failed: {}\", e.getMessage(), e); }","preventionTips":["Only delete IDs that were obtained from this same store/class","Treat 'no matching documents' vs transport errors distinctly by reading the joined messages","Confirm delete permissions on the API key for Weaviate Cloud"],"tags":["weaviate","vector-store","delete"],"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"}