{"record":{"id":"7ee7ef760fa980c5","repo":"spring-projects/spring-ai","slug":"bad-request-s","errorCode":null,"errorMessage":"Bad Request: %s","messagePattern":"Bad Request: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":400,"severity":"error","filePath":"vector-stores/spring-ai-gemfire-store/src/main/java/org/springframework/ai/vectorstore/gemfire/GemFireVectorStore.java","lineNumber":344,"sourceCode":"\t\t\t.block();\n\t}\n\n\t/**\n\t * Handles exceptions that occur during HTTP client operations and maps them to\n\t * appropriate runtime exceptions.\n\t * @param ex the exception that occurred during HTTP client operation\n\t * @return a mapped runtime exception corresponding to the HTTP client exception\n\t */\n\tprivate Throwable handleHttpClientException(Throwable ex) {\n\t\tif (!(ex instanceof WebClientResponseException clientException)) {\n\t\t\tthrow new RuntimeException(String.format(\"Got an unexpected error: %s\", ex));\n\t\t}\n\n\t\tif (clientException.getStatusCode().equals(org.springframework.http.HttpStatus.NOT_FOUND)) {\n\t\t\tthrow new RuntimeException(String.format(\"Index %s not found: %s\", this.indexName, ex));\n\t\t}\n\t\telse if (clientException.getStatusCode().equals(org.springframework.http.HttpStatus.BAD_REQUEST)) {\n\t\t\tthrow new RuntimeException(String.format(\"Bad Request: %s\", ex));\n\t\t}\n\t\telse {\n\t\t\tthrow new RuntimeException(String.format(\"Got an unexpected HTTP error: %s\", ex));\n\t\t}\n\t}\n\n\t@Override\n\tpublic VectorStoreObservationContext.Builder createObservationContextBuilder(String operationName) {\n\t\treturn VectorStoreObservationContext.builder(VectorStoreProvider.GEMFIRE.value(), operationName)\n\t\t\t.collectionName(this.indexName)\n\t\t\t.dimensions(this.embeddingModel.dimensions())\n\t\t\t.fieldName(EMBEDDINGS);\n\t}\n\n\tpublic static class CreateRequest {\n\n\t\t@JsonProperty(\"name\")\n\t\tprivate final String indexName;","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/vector-stores/spring-ai-gemfire-store/src/main/java/org/springframework/ai/vectorstore/gemfire/GemFireVectorStore.java#L326-L362","documentation":"GemFireVectorStore.handleHttpClientException maps a WebClientResponseException with HTTP 400 BAD_REQUEST to RuntimeException(\"Bad Request: %s\"). The server rejected the request payload or parameters sent to the GemFire REST API as malformed or invalid.","triggerScenarios":"Any GemFire vector store operation whose REST request the server answers with 400: malformed query parameters (e.g. invalid limit/k, bad OQL produced by a filter), or an invalid JSON body in put/create-index calls.","commonSituations":"Illegal characters or OQL syntax in filter values, embedding dimension mismatch producing an invalid request body, wrong API path/version for the GemFire server, or overly large payloads.","solutions":["Inspect the chained exception message for the server's 400 detail","Validate request parameters (k, threshold, filter expressions) produce valid GemFire OQL/payloads","Confirm embedding dimensions match the index configuration","Check the GemFire REST API version/path expected by your server release"],"exampleFix":"// before: unescaped quote breaks the server-side query\nnew Filter.Expression(ExpressionType.EQ, new MetadataKey(\"title\"), new MetadataValue(\"it's here\"));\n// after: sanitize metadata values before storing/querying\nnew Filter.Expression(ExpressionType.EQ, new MetadataKey(\"title\"), new MetadataValue(\"its here\"));","handlingStrategy":"try-catch","validationCode":"Objects.requireNonNull(k, \"k must not be null\");\nAssert.isTrue(k > 0 && k <= 1000, \"k out of range\");\n// also sanitize metadata values of OQL-special characters","typeGuard":null,"tryCatchPattern":"try {\n    vectorStore.similaritySearch(SearchRequest.builder().query(q).topK(k).build());\n} catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"Bad Request\")) {\n        logger.error(\"GemFire rejected request: {}\", e.getMessage(), e);\n    }\n    throw e;\n}","preventionTips":["Sanitize metadata values (quotes, OQL operators) before storing/querying","Confirm embedding dimensions match the GemFire index","Keep the REST API path/version in sync with the server release"],"tags":["gemfire","http-400","bad-request","rest-client","vector-store"],"backgroundTag":"http-error-response","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}