{"record":{"id":"f517607ebfaf2365","repo":"chenhg5/cc-connect","slug":"gemini-stt-request-w","errorCode":null,"errorMessage":"gemini stt: request: %w","messagePattern":"gemini stt: request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/speech.go","lineNumber":267,"sourceCode":"\t\t},\n\t}\n\n\tjsonData, err := json.Marshal(reqBody)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"gemini stt: marshal request: %w\", err)\n\t}\n\n\tapiURL := fmt.Sprintf(\"%s/models/%s:generateContent\", g.BaseURL, url.PathEscape(g.Model))\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, apiURL, bytes.NewReader(jsonData))\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"gemini stt: create request: %w\", err)\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Set(\"x-goog-api-key\", g.APIKey)\n\n\tresp, err := g.Client.Do(req)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"gemini stt: request: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\tbody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"gemini stt: read response: %w\", err)\n\t}\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn \"\", fmt.Errorf(\"gemini stt API %d: %s\", resp.StatusCode, string(body))\n\t}\n\n\tvar result struct {\n\t\tCandidates []struct {\n\t\t\tContent struct {\n\t\t\t\tParts []struct {\n\t\t\t\t\tText string `json:\"text\"`\n\t\t\t\t} `json:\"parts\"`","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/speech.go#L249-L285","documentation":"Thrown by GeminiSTT.Transcribe in core/speech.go when the HTTP request to the Gemini API fails at the transport level (g.Client.Do returned an error). This covers DNS failures, connection refused/reset, TLS errors, and context cancellation/timeouts — no HTTP response was received.","triggerScenarios":"g.Client.Do(req) errors: no network connectivity, DNS resolution failure, server unreachable/firewall blocking, TLS certificate problems, or the request context (ctx) is cancelled or times out mid-request.","commonSituations":"Machine offline or behind a restrictive firewall/proxy; generativelanguage.googleapis.com blocked (e.g. in some regions); long audio uploads exceeding the HTTP client timeout; user cancels the operation; corporate MITM proxy with untrusted cert.","solutions":["Check network connectivity and that generativelanguage.googleapis.com is reachable (curl the endpoint).","Inspect the wrapped error: context deadline exceeded -> increase HTTP timeout or reduce audio size; connection refused/blocked -> fix firewall/proxy or use a reachable region.","Configure HTTP(S)_PROXY correctly if behind a corporate proxy.","Retry transient network errors with backoff.","If TLS errors, update the system CA bundle or fix proxy interception."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"conn, err := net.DialTimeout(\"tcp\", \"generativelanguage.googleapis.com:443\", 5*time.Second)\nif err != nil { return fmt.Errorf(\"gemini endpoint unreachable: %w\", err) }\nconn.Close()","typeGuard":null,"tryCatchPattern":"var text string\nvar lastErr error\nfor i := 0; i < 3; i++ {\n    text, lastErr = stt.Transcribe(ctx, audio)\n    if lastErr == nil { break }\n    if errors.Is(lastErr, context.DeadlineExceeded) { break } // don't retry timeouts\n    time.Sleep(time.Duration(1<<i) * time.Second)\n}","preventionTips":["Set a generous HTTP client timeout for large audio uploads.","Verify firewall/proxy allows generativelanguage.googleapis.com:443.","Configure HTTPS_PROXY explicitly in restricted networks.","Check connectivity at startup via a doctor/health check.","Respect ctx cancellation and surface timeouts clearly to the user."],"tags":["network","http","speech-to-text","gemini","timeout"],"backgroundTag":"network-request-failed","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}