{"record":{"id":"9d0df24a5f58fd2c","repo":"Netflix/chaosmonkey","slug":"body-read-failed-at-s-9d0df2","errorCode":null,"errorMessage":"body read failed at %s","messagePattern":"body read failed at (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"spinnaker/spinnaker.go","lineNumber":274,"sourceCode":"\n\tresp, err := s.client.Get(url)\n\tif err != nil {\n\t\treturn \"\", nil, errors.Wrapf(err, \"http get failed at %s\", url)\n\t}\n\n\tdefer func() {\n\t\tif cerr := resp.Body.Close(); cerr != nil && err == nil {\n\t\t\terr = errors.Wrapf(err, \"body close failed at %s\", url)\n\t\t}\n\t}()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn \"\", nil, errors.Errorf(\"unexpected response code (%d) from %s\", resp.StatusCode, url)\n\t}\n\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn \"\", nil, errors.Wrap(err, fmt.Sprintf(\"body read failed at %s\", url))\n\t}\n\n\tvar data struct {\n\t\tName      string\n\t\tInstances []struct{ Name string }\n\t}\n\n\terr = json.Unmarshal(body, &data)\n\tif err != nil {\n\t\treturn \"\", nil, errors.Wrapf(err, \"failed to parse json at %s\", url)\n\t}\n\n\tasg := D.ASGName(data.Name)\n\tinstances := make([]D.InstanceID, len(data.Instances))\n\tfor i, instance := range data.Instances {\n\t\tinstances[i] = D.InstanceID(instance.Name)\n\t}\n","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/Netflix/chaosmonkey/blob/eaa28fb761c0ebe8644d1333e5d164e9cc3071e9/spinnaker/spinnaker.go#L256-L292","documentation":"Spinnaker.GetInstanceIDs throws this when ioutil.ReadAll fails while reading the response body from a 200-OK response. The library wraps the read error with the URL. This usually means the connection was cut off mid-body — the response was truncated or the stream errored before EOF.","triggerScenarios":"Calling GetInstanceIDs when the TCP connection is reset or times out while the body is being transferred, a proxy or load balancer terminates the connection early, or the server aborts the response mid-stream.","commonSituations":"Large cluster listings over flaky networks; aggressive LB idle timeouts killing slow responses; proxy (e.g. corporate proxy) dropping chunked responses; Spinnaker gateway restarts mid-request.","solutions":["Retry the request; transient connection resets are the usual cause.","Check proxy/LB idle and response timeouts and raise them for slow endpoints.","Ensure the HTTP client timeout is long enough to receive the full body.","Check network stability between the client and Spinnaker gate.","If bodies are consistently large, paginate or reduce the data requested."],"exampleFix":"// before\nclient := &http.Client{}\n// after\nclient := &http.Client{Timeout: 60 * time.Second} // allow full body transfer\n// and/or retry:\nfor i := 0; i < 3; i++ {\n    asg, ids, err := sp.GetInstanceIDs(app, acct, cp, region, cluster)\n    if err == nil { break }\n}","handlingStrategy":"retry","validationCode":"// confirm network path is stable before batch operations\nif err := pingEndpoint(baseURL); err != nil {\n    return fmt.Errorf(\"spinnaker unreachable, skipping batch: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"// Go: retry with backoff on read errors\nfor attempt := 0; attempt < 3; attempt++ {\n    asg, ids, err := sp.GetInstanceIDs(app, acct, cp, region, cluster)\n    if err == nil {\n        return asg, ids, nil\n    }\n    if strings.Contains(err.Error(), \"body read failed\") {\n        time.Sleep(time.Duration(1<<attempt) * 500 * time.Millisecond)\n        continue\n    }\n    return asg, ids, err\n}\nreturn \"\", nil, errors.New(\"body read failed after retries\")","preventionTips":["Set generous HTTP client timeouts for large responses","Raise LB/proxy idle timeouts","Retry idempotent GETs on failure","Monitor proxy/gateway abort rates"],"tags":["http","network","io","spinnaker"],"backgroundTag":"response-body-read-failed","analyzedSha":"eaa28fb761c0ebe8644d1333e5d164e9cc3071e9","analyzedAt":"2026-09-03T17:04:39.020Z","contentChangedAt":"2026-09-03T17:04:39.020Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}