spring-projects/spring-ai · error · RuntimeException
Failed to delete documents because:
Error message
Failed to delete documents because:
What it means
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.
Source
Thrown at vector-stores/spring-ai-weaviate-store/src/main/java/org/springframework/ai/vectorstore/weaviate/WeaviateVectorStore.java:289
Result<BatchDeleteResponse> result = this.weaviateClient.batch()
.objectsBatchDeleter()
.withClassName(this.options.getObjectClass())
.withConsistencyLevel(this.consistencyLevel.name())
.withWhere(WhereFilter.builder()
.path("id")
.operator(Operator.ContainsAny)
.valueString(documentIds.toArray(new String[0]))
.build())
.run();
if (result.hasErrors()) {
String errorMessages = result.getError()
.getMessages()
.stream()
.map(WeaviateErrorMessage::getMessage)
.collect(Collectors.joining(","));
throw new RuntimeException("Failed to delete documents because: \n" + errorMessages);
}
}
@Override
protected void doDelete(Filter.Expression filterExpression) {
Assert.notNull(filterExpression, "Filter expression must not be null");
try {
// Use similarity search with empty query to find documents matching the
// filter
SearchRequest searchRequest = SearchRequest.builder()
.query("") // empty query since we only want filter matches
.filterExpression(filterExpression)
.topK(10000) // large enough to get all matches
.similarityThresholdAll()
.build();
List<Document> matchingDocs = similaritySearch(searchRequest);View on GitHub (pinned to 98a7beda4f)
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.
Defensive patterns
Strategy: try-catch
Validate before calling
// confirm the class exists before deleting
GET {weaviateUrl}/v1/schema/{className} -> 200 expected; also verify IDs are UUIDs before calling delete Try / catch
try { vectorStore.delete(ids); } catch (RuntimeException e) { log.error("Weaviate batch delete failed: {}", e.getMessage(), e); } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to delete documents by filter
- Failed to delete documents by filter
- Failed to delete documents by filter
- Delete operation failed
- Failed to delete documents by filter
AI-assisted analysis of spring-projects/spring-ai@98a7beda4f (2026-09-11).
Data as JSON: /api/errors/78090857ab1d9b82.
Report an issue: GitHub.