{"record":{"id":"67b8160255731476","repo":"spring-projects/spring-ai","slug":"request-failed-67b816","errorCode":null,"errorMessage":"Request failed","messagePattern":"Request failed","errorType":"exception","errorClass":"OpenAIIoException","httpStatus":null,"severity":"critical","filePath":"models/spring-ai-openai/src/main/java/org/springframework/ai/openai/http/okhttp/SpringAiOpenAiHttpClient.java","lineNumber":119,"sourceCode":"\t\tthis.ownsDispatcherExecutor = ownsDispatcherExecutor;\n\t}\n\n\tpublic OkHttpClient getOkHttpClient() {\n\t\treturn this.okHttpClient;\n\t}\n\n\tpublic static Builder builder() {\n\t\treturn new Builder();\n\t}\n\n\t@Override\n\tpublic HttpResponse execute(HttpRequest request, RequestOptions requestOptions) {\n\t\tCall call = newCall(request, requestOptions);\n\t\ttry {\n\t\t\treturn toHttpResponse(call.execute());\n\t\t}\n\t\tcatch (IOException e) {\n\t\t\tthrow new OpenAIIoException(\"Request failed\", e);\n\t\t}\n\t\tfinally {\n\t\t\tHttpRequestBody body = request.body();\n\t\t\tif (body != null) {\n\t\t\t\tbody.close();\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override\n\tpublic CompletableFuture<HttpResponse> executeAsync(HttpRequest request, RequestOptions requestOptions) {\n\t\tCompletableFuture<HttpResponse> future = new CompletableFuture<>();\n\n\t\tCall call = newCall(request, requestOptions);\n\t\tcall.enqueue(new Callback() {\n\t\t\t@Override\n\t\t\tpublic void onResponse(Call call, Response response) {\n\t\t\t\tfuture.complete(toHttpResponse(response));","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/models/spring-ai-openai/src/main/java/org/springframework/ai/openai/http/okhttp/SpringAiOpenAiHttpClient.java#L101-L137","documentation":"SpringAiOpenAiHttpClient.execute performs the OkHttp call synchronously; any IOException (DNS failure, connect timeout, socket reset, TLS error) is wrapped in an OpenAIIoException with the message 'Request failed' and the original exception as cause.","triggerScenarios":"Any OpenAI API call through the OkHttp client when the HTTP layer throws IOException — network outage, wrong base URL, proxy/firewall blocking, TLS handshake failure, or read/write timeout.","commonSituations":"Corporate proxies without proxy configuration, VPN dropping mid-request, DNS not resolving api.openai.com, or overly aggressive timeouts on large requests.","solutions":["Inspect the cause chain (e.getCause()) to find the underlying IOException and its concrete reason.","Verify network reachability and the configured base URL / proxy settings.","Increase connect/read timeouts in the client builder and add retry with backoff for transient IO errors."],"exampleFix":"try {\n    return client.execute(request, requestOptions);\n}\ncatch (OpenAIIoException e) {\n    logger.warn(\"OpenAI request failed: {}\", e.getCause() == null ? e.getMessage() : e.getCause().getMessage());\n    throw e;\n}","handlingStrategy":"retry","validationCode":"// pre-flight\nInetAddress.getByName(\"api.openai.com\"); // fails fast if DNS/network is broken","typeGuard":null,"tryCatchPattern":"try {\n    return model.call(request);\n} catch (OpenAIIoException e) {\n    Throwable cause = e.getCause();\n    if (cause instanceof java.net.SocketTimeoutException) {\n        // retry with backoff or increase timeouts\n    }\n    throw new UpstreamUnavailableException(\"OpenAI request failed\", e);\n}","preventionTips":["Configure proxy settings for corporate networks","Set generous connect/read timeouts","Add retry with exponential backoff for transient IO errors","Check e.getCause() to distinguish DNS, timeout, and TLS failures"],"tags":["network","io","okhttp","http-client"],"backgroundTag":"network-request-failed","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}