{"record":{"id":"276b09dc8d33a095","repo":"spring-projects/spring-ai","slug":"joined-weaviate-error-messages-from-graphql-respo","errorCode":null,"errorMessage":"<joined Weaviate error messages from GraphQL response>","messagePattern":"<joined Weaviate error messages from GraphQL response>","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"vector-stores/spring-ai-weaviate-store/src/main/java/org/springframework/ai/vectorstore/weaviate/WeaviateVectorStore.java","lineNumber":361,"sourceCode":"\t\t\t.fields(Fields.builder().fields(this.weaviateSimilaritySearchFields).build());\n\n\t\tString graphQLQuery = queryBuilder.build().buildQuery();\n\n\t\tif (request.hasFilterExpression()) {\n\t\t\tAssert.state(request.getFilterExpression() != null, \"filter expression must not be null\");\n\t\t\t// replace the empty 'where:{}' placeholder with real filter.\n\t\t\tString filter = this.filterExpressionConverter.convertExpression(request.getFilterExpression());\n\t\t\tgraphQLQuery = graphQLQuery.replace(\"where:{}\", String.format(\"where:{%s}\", filter));\n\t\t}\n\t\telse {\n\t\t\t// remove the empty 'where:{}' placeholder.\n\t\t\tgraphQLQuery = graphQLQuery.replace(\"where:{}\", \"\");\n\t\t}\n\n\t\tResult<GraphQLResponse> result = this.weaviateClient.graphQL().raw().withQuery(graphQLQuery).run();\n\n\t\tif (result.hasErrors()) {\n\t\t\tthrow new IllegalArgumentException(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(System.lineSeparator())));\n\t\t}\n\n\t\tGraphQLError[] errors = result.getResult().getErrors();\n\t\tif (errors != null && errors.length > 0) {\n\t\t\tthrow new IllegalArgumentException(Arrays.stream(errors)\n\t\t\t\t.map(GraphQLError::getMessage)\n\t\t\t\t.collect(Collectors.joining(System.lineSeparator())));\n\t\t}\n\n\t\t@SuppressWarnings(\"unchecked\")\n\t\tOptional<Map.Entry<String, Map<?, ?>>> resGetPart = ((Map<String, Map<?, ?>>) result.getResult().getData())\n\t\t\t.entrySet()\n\t\t\t.stream()\n\t\t\t.findFirst();","sourceCodeStart":343,"sourceCodeEnd":379,"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#L343-L379","documentation":"doSimilaritySearch runs a raw GraphQL query against Weaviate. If the Result wrapper reports errors (transport/protocol level), the joined WeaviateErrorMessage messages are thrown as IllegalArgumentException. The query never produced usable data.","triggerScenarios":"VectorStore.similaritySearch(SearchRequest) when the raw GraphQL .run() returns hasErrors() — invalid GraphQL syntax after filter substitution, unknown class/field names, authentication failure, or server error.","commonSituations":"Filter expressions translating to GraphQL where clauses the server rejects; querying a renamed/deleted class; wrong field names in options (contentFieldName) after schema change; expired Weaviate Cloud credentials.","solutions":["Read the joined messages in the IllegalArgumentException — they contain the GraphQL error text from Weaviate.","Log/copy the generated graphQLQuery and run it directly against Weaviate (e.g. via GraphiQL or curl) to see the failing part.","Verify the configured objectClass and field names still exist in the server schema.","If a filter triggered it, simplify or validate the Filter.Expression against supported operators for Weaviate."],"exampleFix":"// before\nvectorStore.similaritySearch(SearchRequest.builder().query(\"q\").topK(5).build()); // throws with joined GraphQL errors\n// after\ntry {\n    vectorStore.similaritySearch(request);\n} catch (IllegalArgumentException e) {\n    logger.error(\"Weaviate GraphQL query failed: {}\", e.getMessage());\n}","handlingStrategy":"try-catch","validationCode":"// sanity-check schema before searching\nGET {weaviateUrl}/v1/schema and confirm the configured objectClass and field names exist","typeGuard":null,"tryCatchPattern":"try { vectorStore.similaritySearch(req); } catch (IllegalArgumentException e) { log.error(\"Weaviate GraphQL failed: {}\", e.getMessage()); }","preventionTips":["Log the generated graphQLQuery and test it in GraphiQL when searches fail","Keep class/property names in store options matching the live schema","Renew Weaviate Cloud credentials before expiry"],"tags":["weaviate","graphql","similarity-search"],"backgroundTag":"graphql-errors-response","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}