{"record":{"id":"06752feba4cd7010","repo":"sipeed/picoclaw","slug":"reading-userinfo-response-w","errorCode":null,"errorMessage":"reading userinfo response: %w","messagePattern":"reading userinfo response: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/picoclaw/internal/auth/helpers.go","lineNumber":253,"sourceCode":"}\n\nfunc fetchGoogleUserEmail(accessToken string) (string, error) {\n\treq, err := http.NewRequest(\"GET\", \"https://www.googleapis.com/oauth2/v2/userinfo\", nil)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treq.Header.Set(\"Authorization\", \"Bearer \"+accessToken)\n\n\tclient := &http.Client{Timeout: 10 * time.Second}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn \"\", 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(\"reading userinfo response: %w\", err)\n\t}\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn \"\", fmt.Errorf(\"userinfo request failed: %s\", string(body))\n\t}\n\n\tvar userInfo struct {\n\t\tEmail string `json:\"email\"`\n\t}\n\tif err := json.Unmarshal(body, &userInfo); err != nil {\n\t\treturn \"\", err\n\t}\n\treturn userInfo.Email, nil\n}\n\nfunc authLoginPasteToken(provider string) error {\n\tcred, err := auth.LoginPasteToken(provider, os.Stdin)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"login failed: %w\", err)","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/cmd/picoclaw/internal/auth/helpers.go#L235-L271","documentation":"Context wrapper in fetchGoogleUserEmail around io.ReadAll of the userinfo response body: the HTTP request to googleapis.com succeeded (status not yet checked), but streaming the body failed mid-read — typically a dropped connection or client timeout (10s). The access token was accepted far enough to get a response; the email just could not be read.","triggerScenarios":"Thrown at cmd/picoclaw/internal/auth/helpers.go:253 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the request — mid-body connection drops are usually transient","Increase the 10s client timeout on slow links","Check network stability / proxy behavior for long-lived responses"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","contentChangedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}