{"record":{"id":"aaf9df336040f38d","repo":"chenhg5/cc-connect","slug":"googlechat-send-preview-w","errorCode":null,"errorMessage":"googlechat: send preview: %w","messagePattern":"googlechat: send preview: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/googlechat/streaming.go","lineNumber":44,"sourceCode":"\trc, ok := rctx.(replyContext)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"googlechat: invalid reply context type %T\", rctx)\n\t}\n\tif rc.space == \"\" {\n\t\treturn nil, fmt.Errorf(\"googlechat: missing space in reply context\")\n\t}\n\turl, body, err := buildSendRequest(rc, content)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(body))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"googlechat: build request: %w\", err)\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\tresp, err := p.doRequest(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"googlechat: send preview: %w\", err)\n\t}\n\tdefer func() {\n\t\tif err := resp.Body.Close(); err != nil {\n\t\t\tslog.Warn(\"googlechat: close preview response body\", \"error\", err)\n\t\t}\n\t}()\n\tvar msg struct {\n\t\tName string `json:\"name\"`\n\t}\n\tif err := json.NewDecoder(resp.Body).Decode(&msg); err != nil {\n\t\treturn nil, fmt.Errorf(\"googlechat: parse create response: %w\", err)\n\t}\n\t// drain any bytes json.Decoder left unread so the connection is reusable\n\t_, _ = io.Copy(io.Discard, resp.Body)\n\tif msg.Name == \"\" {\n\t\treturn nil, fmt.Errorf(\"googlechat: create response missing message name\")\n\t}\n\treturn &previewHandle{name: msg.Name}, nil","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/googlechat/streaming.go#L26-L62","documentation":"Wraps an error from p.doRequest when actually sending the preview message POST to the Google Chat API. This covers transport-level failures: DNS, connection refused, TLS, timeouts, or cancelled context — not HTTP error statuses.","triggerScenarios":"Network outage or proxy blocking chat.googleapis.com; context deadline exceeded during slow networks; TLS certificate problems on the host.","commonSituations":"Firewalled servers without egress to Google APIs; DNS misconfiguration; expired system CA bundles; long-running streams on flaky networks.","solutions":["Test egress connectivity: curl https://chat.googleapis.com from the host","Check proxy env vars (HTTPS_PROXY) and TLS/CA configuration","Retry the preview send; the engine's streaming flow is naturally retry-tolerant","Increase context timeouts if previews fail on slow links"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if _, err := p.SendPreviewStart(ctx, rc, content); err != nil {\n    if errors.Is(err, context.DeadlineExceeded) || isTransientNetwork(err) {\n        return retryWithBackoff(ctx, 3, func() error { _, err := p.SendPreviewStart(ctx, rc, content); return err })\n    }\n    return err\n}","preventionTips":["Verify outbound HTTPS access to chat.googleapis.com during deployment","Set generous but bounded context timeouts for streaming sends","Check HTTPS_PROXY and CA bundle configuration","Add exponential backoff around preview sends"],"tags":["googlechat","network","streaming","http"],"backgroundTag":"http-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"}