spring-projects/spring-ai · error · IllegalStateException
Failed to delete documents by filter
Error message
Failed to delete documents by filter
What it means
doDelete(Filter.Expression) fetches candidate IDs via a GraphQL query, deserializes response JSON with JsonMapper, then deletes. A JacksonException during parsing is rethrown as IllegalStateException('Failed to delete documents by filter'). The response body did not match the expected JSON structure.
Source
Thrown at vector-stores/spring-ai-weaviate-store/src/main/java/org/springframework/ai/vectorstore/weaviate/WeaviateVectorStore.java:324
List<Document> matchingDocs = similaritySearch(searchRequest);
if (!matchingDocs.isEmpty()) {
List<String> idsToDelete = matchingDocs.stream().map(Document::getId).toList();
delete(idsToDelete);
if (logger.isDebugEnabled()) {
logger.debug("Deleted " + idsToDelete.size() + " documents matching filter expression");
}
}
else {
logger.debug("No documents found matching filter expression");
}
}
catch (JacksonException e) {
logger.error("Failed to delete documents by filter", e);
throw new IllegalStateException("Failed to delete documents by filter", e);
}
}
@Override
public List<Document> doSimilaritySearch(SearchRequest request) {
float[] embedding = this.embeddingModel.embed(request.getQuery());
GetBuilder.GetBuilderBuilder builder = GetBuilder.builder();
GetBuilderBuilder queryBuilder = builder.className(this.options.getObjectClass())
.withNearVectorFilter(NearVectorArgument.builder()
.vector(EmbeddingUtils.toFloatArray(embedding))
.certainty((float) request.getSimilarityThreshold())
.build())
.limit(request.getTopK())
.withWhereFilter(WhereArgument.builder().build()) // adds an empty 'where:{}'
// placeholder.View on GitHub (pinned to 98a7beda4f)
Solutions
- Check server/client version compatibility: align Weaviate server version with the version supported by your spring-ai-weaviate-store release.
- Look at the logged stack trace (logger.error already logs it) to see the exact Jackson path that failed.
- Capture the raw GraphQL response with curl to compare its shape against the parser's expectations.
- If a proxy is in front of Weaviate, bypass it or fix it to return JSON for GraphQL endpoints.
Defensive patterns
Strategy: try-catch
Try / catch
try { vectorStore.delete(filterExpr); } catch (IllegalStateException e) { log.error("Filter-based delete failed to parse Weaviate response", e); /* check server/client version alignment */ } Prevention
- Keep the Weaviate server version aligned with the spring-ai-weaviate-store release notes
- Ensure no proxy rewrites GraphQL responses into HTML error pages
- Reproduce the raw GraphQL response with curl when deserialization fails
When it happens
Trigger: VectorStore.delete(Filter.Expression) when the GraphQL _additional id response cannot be parsed — unexpected response shape, Weaviate version returning a different field layout, or truncated/corrupt response.
Common situations: Upgrading Weaviate server to a version with changed GraphQL response format while using an older spring-ai-weaviate-store; proxy/gateway returning an HTML error page; empty data maps being interpreted incorrectly.
Related errors
- Invalid JSON format for the response:
- Cannot deserialize ThinkOption from token:
- Conversion from JSON to %s failed
- Failed to serialize the Document metadata:
- Failed to delete documents because:
AI-assisted analysis of spring-projects/spring-ai@98a7beda4f (2026-09-11).
Data as JSON: /api/errors/2d004342af8820a9.
Report an issue: GitHub.