{"record":{"id":"3a77def8e2691523","repo":"spring-projects/spring-ai","slug":"joined-graphql-error-messages","errorCode":null,"errorMessage":"<joined GraphQL error messages>","messagePattern":"<joined GraphQL error messages>","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":370,"sourceCode":"\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();\n\t\tif (!resGetPart.isPresent()) {\n\t\t\treturn List.of();\n\t\t}\n\n\t\tOptional<?> resItemsPart = resGetPart.get().getValue().entrySet().stream().findFirst();\n\t\tif (!resItemsPart.isPresent()) {\n\t\t\treturn List.of();\n\t\t}\n","sourceCodeStart":352,"sourceCodeEnd":388,"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#L352-L388","documentation":"Even when the HTTP-level Result has no errors, the GraphQL response body can carry GraphQLError[] entries (application-level GraphQL errors). doSimilaritySearch joins their messages and throws IllegalArgumentException. This distinguishes protocol success from query-level failure.","triggerScenarios":"VectorStore.similaritySearch(SearchRequest) where result.getResult().getErrors() is non-empty — e.g. GraphQL validation errors (unknown field/argument), where-filter type errors, or partial resolver failures reported in the 200 response body.","commonSituations":"Using Filter operators unsupported by the Weaviate where-filter grammar; mismatch between filterMetadataFields types and schema property types (string vs int); querying nearVector on a class without a vectorizer configured.","solutions":["Read the joined GraphQL error messages in the exception — they pinpoint the invalid field/argument.","Validate the where-filter structure: property names must exist in the Weaviate class with matching value types.","Test the generated query in a GraphQL IDE against the live schema to confirm field names.","Update the spring-ai-weaviate-store module if the server schema introduced newer GraphQL features the client emits incorrectly."],"exampleFix":"// before\nFilterExpressionBuilder b = new FilterExpressionBuilder();\n// searching on metadata field 'age' stored as string but filtered as number -> GraphQL error\n// after\n// declare MetadataField with the type matching the Weaviate schema property:\nnew WeaviateVectorStore.builder(client, embeddingModel)\n    .filterMetadataFields(List.of(new MetadataField(\"age\", MetadataField.MetadataFieldType.NUMBER)))\n    .build();","handlingStrategy":"try-catch","validationCode":"// ensure filter fields exist with matching types\nSet<String> props = schema.getClass(objectClass).getProperties().stream().map(p -> p.getName()).collect(toSet());\nfilterFields.forEach(f -> { if (!props.contains(f.name())) throw new IllegalStateException(\"Unknown filter field: \" + f.name()); });","typeGuard":null,"tryCatchPattern":"try { vectorStore.similaritySearch(req); } catch (IllegalArgumentException e) { /* message contains joined GraphQLError messages naming the invalid field */ }","preventionTips":["Match MetadataField types (STRING/NUMBER/BOOLEAN) to actual Weaviate property types","Use only Filter operators supported by Weaviate where-filters","Validate filters against the schema in integration tests"],"tags":["weaviate","graphql","similarity-search","filter"],"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"}