{"record":{"id":"01a197e0dfe42565","repo":"googleapis/mcp-toolbox","slug":"failed-to-send-request-w","errorCode":null,"errorMessage":"failed to send request: %w","messagePattern":"failed to send request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/bigquery/bigqueryconversationalanalytics/bigqueryconversationalanalytics.go","lineNumber":285,"sourceCode":"}\n\nfunc getStream(client *http.Client, url string, payload CAPayload, headers map[string]string, maxRows int) (string, error) {\n\tpayloadBytes, err := json.Marshal(payload)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to marshal payload: %w\", err)\n\t}\n\n\treq, err := http.NewRequest(\"POST\", url, bytes.NewBuffer(payloadBytes))\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to create request: %w\", err)\n\t}\n\tfor k, v := range headers {\n\t\treq.Header.Set(k, v)\n\t}\n\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to send request: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\tbody, _ := io.ReadAll(resp.Body)\n\t\treturn \"\", fmt.Errorf(\"API returned non-200 status: %d %s\", resp.StatusCode, string(body))\n\t}\n\n\tvar messages []map[string]any\n\tdecoder := json.NewDecoder(resp.Body)\n\tdataMsgIdx := -1\n\n\t// The response is a JSON array, so we read the opening bracket.\n\tif _, err := decoder.Token(); err != nil {\n\t\tif err == io.EOF {\n\t\t\treturn \"\", nil // Empty response is valid\n\t\t}\n\t\treturn \"\", fmt.Errorf(\"error reading start of json array: %w\", err)","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/bigquery/bigqueryconversationalanalytics/bigqueryconversationalanalytics.go#L267-L303","documentation":"This error wraps a failure from client.Do(req) when sending the POST to the Conversational Analytics API. It covers transport-level failures: DNS resolution errors, connection refused/reset, TLS handshake failures, timeouts, or context cancellation.","triggerScenarios":"Invoke on the tool when the HTTP client (built from the source's token source) cannot reach the GDA endpoint: no network, blocked egress, DNS failure, TLS problems, or the request context is canceled before completion.","commonSituations":"Corporate firewall/proxy blocking api.googleapis.com; missing VPC Service Controls egress rules; running in an air-gapped environment; expired/unrefreshable credentials causing token-source failures surfaced as transport errors; long-running queries exceeding client timeouts.","solutions":["Verify network egress to the Conversational Analytics endpoint (DNS + HTTPS) from the host running the toolbox (curl the endpoint).","Check application default credentials: run `gcloud auth application-default login` or provide a valid service account via GOOGLE_APPLICATION_CREDENTIALS.","If behind a proxy, set HTTPS_PROXY correctly; if in VPC-SC, add the required egress rule for the API.","Check whether the request context was canceled upstream (client disconnect/timeout) and increase timeouts if needed.","Retry with backoff for transient connection resets."],"exampleFix":"// before: no egress\n//   firewall blocks api.googleapis.com\n// after: allow egress\n//   gcloud services enable cloudaicompanion.googleapis.com\n//   open HTTPS (443) to googleapis.com in firewall/proxy","handlingStrategy":"retry","validationCode":"conn, err := net.DialTimeout(\"tcp\", \"api.googleapis.com:443\", 5*time.Second)\nif err != nil {\n    return fmt.Errorf(\"no network egress to GDA endpoint: %w\", err)\n}\nconn.Close()","typeGuard":null,"tryCatchPattern":"var result any\nerr := retry.Do(3, time.Second, func() error {\n    var e error\n    result, e = tool.Invoke(ctx, params)\n    return e\n})\nif err != nil {\n    return fmt.Errorf(\"GDA unreachable after retries: %w\", err)\n}","preventionTips":["Verify firewall/egress allows HTTPS to googleapis.com endpoints.","Configure HTTP(S)_PROXY correctly in containerized deployments.","Refresh application default credentials before long-running sessions.","Set generous HTTP client timeouts for streaming responses."],"tags":["network","http","google-cloud","bigquery"],"backgroundTag":"http-request-failed","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}