{"record":{"id":"7bd6ef03f9ef2503","repo":"spring-projects/spring-ai","slug":"got-an-unexpected-http-error-s","errorCode":null,"errorMessage":"Got an unexpected HTTP error: %s","messagePattern":"Got an unexpected HTTP error: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"vector-stores/spring-ai-gemfire-store/src/main/java/org/springframework/ai/vectorstore/gemfire/GemFireVectorStore.java","lineNumber":347,"sourceCode":"\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;\n\n\t\t@JsonProperty(\"beam-width\")\n\t\tprivate final int beamWidth;","sourceCodeStart":329,"sourceCodeEnd":365,"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#L329-L365","documentation":"GemFireVectorStore's handleHttpClientException converts REST client exceptions into RuntimeExceptions. When the HTTP status is neither NOT_FOUND nor BAD_REQUEST (e.g. 500, 503, 401), it throws this generic 'Got an unexpected HTTP error' wrapping the original exception. It signals that GemFire's REST management endpoint rejected the request in a way the store does not specifically classify.","triggerScenarios":"Calling GemFireVectorStore operations (e.g. afterPropertiesSet creating the index, similaritySearch, add) when the GemFire REST call returns an HTTP status other than 404 or 400 — server-side 500 errors, auth failures (401/403), gateway 502/503.","commonSituations":"GemFire server overloaded or crashing, wrong management endpoint URL/port, missing security credentials, GemFire version returning non-standard status codes, proxy/load balancer intercepting requests.","solutions":["Inspect the wrapped exception 'ex' message in the stack trace to find the real HTTP status and server response body.","Verify gemfire.host/port and management endpoint configuration point to a running GemFire cluster.","Check GemFire server logs for the corresponding 5xx error and fix the server-side cause.","If auth-related, supply correct credentials for the GemFire REST API.","Retry the operation if the failure was transient (503/overload)."],"exampleFix":"// before\nvectorStore.similaritySearch(query); // opaque RuntimeException\n// after\ntry {\n    vectorStore.similaritySearch(query);\n} catch (RuntimeException e) {\n    logger.error(\"GemFire HTTP call failed: {}\", e.getCause(), e);\n    // inspect cause for HTTP status, then retry or reconfigure\n}","handlingStrategy":"try-catch","validationCode":"// Optionally pre-check GemFire REST endpoint health before store ops:\n// curl -f http://${host}:${port}/gemfire/v1 && echo ok\nboolean gemfireReachable(String host, int port) {\n    try (var s = new java.net.Socket(host, port)) { return true; }\n    catch (java.io.IOException e) { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n    vectorStore.similaritySearch(request);\n} catch (RuntimeException e) {\n    Throwable cause = e.getCause();\n    // log cause (HTTP status + body), decide retry vs reconfigure\n}","preventionTips":["Health-check the GemFire management REST endpoint before starting the app.","Pin and verify gemfire host/port/credentials per environment.","Monitor GemFire server logs alongside application logs.","Wrap store calls with a retry policy for transient 5xx."],"tags":["http","gemfire","vector-store","rest-client"],"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"}