{"record":{"id":"9551995a7df3ce05","repo":"bytebase/bytebase","slug":"failed-to-send-http-request","errorCode":null,"errorMessage":"failed to send HTTP request","messagePattern":"failed to send HTTP request","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/plugin/db/elasticsearch/elasticsearch.go","lineNumber":447,"sourceCode":"\t\t\t\t\trequestPath = \"/\" + requestPath\n\t\t\t\t}\n\n\t\t\t\treq, err := http.NewRequest(request.Method, requestPath, bytes.NewReader(data))\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn errors.Wrapf(err, \"failed to create HTTP request\")\n\t\t\t\t}\n\t\t\t\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\t\t\t\t// Use OpenSearch client's Stream method which handles AWS signing\n\t\t\t\tresp, err = d.opensearchClient.Stream(req)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn errors.Wrapf(err, \"failed to send HTTP request via OpenSearch client\")\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// For basic auth, use the basic auth client as before\n\t\t\t\tresp, err = d.basicAuthClient.Do(request.Method, []byte(request.URL), data)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn errors.Wrapf(err, \"failed to send HTTP request\")\n\t\t\t\t}\n\t\t\t}\n\t\t\tdefer resp.Body.Close()\n\n\t\t\trespBytes, err := io.ReadAll(resp.Body)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrap(err, \"failed to read response body\")\n\t\t\t}\n\n\t\t\t// Check HTTP status code for errors (4xx, 5xx)\n\t\t\tif resp.StatusCode >= 400 {\n\t\t\t\treturn errors.Errorf(\"request failed with status code %d: %s\", resp.StatusCode, string(respBytes))\n\t\t\t}\n\n\t\t\t// structure results.\n\t\t\tvar result v1pb.QueryResult\n\t\t\tvar row v1pb.QueryRow\n","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/bytebase/bytebase/blob/1870550677fe08f0d2a78c07acd27541464eb945/backend/plugin/db/elasticsearch/elasticsearch.go#L429-L465","documentation":"Raised in QueryConn when the basic-auth fallback HTTP client fails to send the parsed REST statement (transport-level error, no usable response). The underlying network error is wrapped and preserved as the cause.","triggerScenarios":"QueryConn on the non-IAM path: d.basicAuthClient.Do(request.Method, request.URL, data) returns err != nil — connection refused, DNS failure, TLS error, or request timeout while executing the user's REST statement.","commonSituations":"Cluster unreachable or down at execution time; request URL from the statement forming an unreachable target (bad host baked into the address); TLS mismatch; long-running _search/_bulk timing out due to network limits.","solutions":["Inspect the wrapped cause for the concrete network failure.","Verify the cluster is up and reachable (Ping or curl the root endpoint) before running the statement.","Check the statement's target path/host and the configured data source address for mismatches.","Address timeout/firewall issues if the statement is large (e.g. _bulk) or the network is constrained."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"const ok = await fetch(dataSource.address + \"/\", { signal: AbortSignal.timeout(5000) }).then(r => r.ok).catch(() => false);\nif (!ok) throw new Error(\"basic-auth endpoint unreachable; fix address/network before running statements\");","typeGuard":null,"tryCatchPattern":"try {\n  await driver.queryConn(ctx, conn, statement, qctx);\n} catch (e) {\n  if (String(e).includes(\"failed to send HTTP request\")) {\n    // check e.cause for refused/timeout/TLS and retry transient network errors\n  }\n  throw e;\n}","preventionTips":["Ping the instance before batch executions to catch outages early","Ensure the statement's target path is valid for the configured host","Set sensible timeouts and handle large _bulk payloads in chunks"],"tags":["elasticsearch","http-request","network","query-execution"],"backgroundTag":"network-request-failed","analyzedSha":"1870550677fe08f0d2a78c07acd27541464eb945","analyzedAt":"2026-09-06T21:16:13.665Z","contentChangedAt":"2026-09-06T21:16:13.665Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}