{"record":{"id":"e2941ad05c815d59","repo":"chenhg5/cc-connect","slug":"googlechat-drain-update-response-body-w","errorCode":null,"errorMessage":"googlechat: drain update response body: %w","messagePattern":"googlechat: drain update response body: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"platform/googlechat/streaming.go","lineNumber":98,"sourceCode":"\tif !ok {\n\t\treturn fmt.Errorf(\"googlechat: invalid preview handle type %T\", handle)\n\t}\n\turl, body, err := buildUpdateRequest(h.name, content)\n\tif err != nil {\n\t\treturn err\n\t}\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPatch, url, bytes.NewReader(body))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"googlechat: build update 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 err\n\t}\n\tif _, err := io.Copy(io.Discard, resp.Body); err != nil {\n\t\t_ = resp.Body.Close()\n\t\treturn fmt.Errorf(\"googlechat: drain update response body: %w\", err)\n\t}\n\tif err := resp.Body.Close(); err != nil {\n\t\treturn fmt.Errorf(\"googlechat: close update response body: %w\", err)\n\t}\n\treturn nil\n}\n\nvar (\n\t_ core.MessageUpdater = (*Platform)(nil)\n\t_ core.PreviewStarter = (*Platform)(nil)\n)\n","sourceCodeStart":80,"sourceCodeEnd":110,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/googlechat/streaming.go#L80-L110","documentation":"This error is returned by Platform.UpdateMessage in platform/googlechat/streaming.go when the response body of a Google Chat message-update HTTP request cannot be fully drained (io.Copy to io.Discard fails). Draining the body is required so the underlying TCP connection can be reused; a failure here indicates the response stream broke mid-read (connection reset, context cancellation, timeout). The original update may or may not have been applied server-side.","triggerScenarios":"Calling UpdateMessage when the Google Chat API closes the connection before the response body finishes streaming, the request context is cancelled mid-read, or a proxy/load balancer truncates the response.","commonSituations":"Flaky networks or corporate proxies between the server and Google's API; long-lived streaming update loops hitting transient connection resets; request deadlines expiring during large responses.","solutions":["Retry UpdateMessage with backoff; the update is idempotent (same message ID and content).","Check network stability / proxy configuration between the host and googleapis.com.","Ensure the context passed into the request is not cancelled prematurely (e.g. short HTTP client timeouts).","If it persists, inspect whether a body-size-limiting proxy or WAF is interfering with googleapis.com responses."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Go: caller of UpdateMessage\nfor attempt := 0; attempt < 3; attempt++ {\n    err := platform.UpdateMessage(ctx, msgID, content)\n    if err == nil || !strings.Contains(err.Error(), \"drain update response body\") {\n        break\n    }\n    time.Sleep(backoff(attempt))\n}","preventionTips":["Use generous-but-bounded HTTP client timeouts so reads don't get cut off mid-drain.","Avoid cancelling contexts while a response body is being read.","Monitor for recurring resets and check proxy/NAT idle timeouts toward googleapis.com."],"tags":["googlechat","network","http-response-drain"],"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"}