{"record":{"id":"105d103cd223fc1a","repo":"Netflix/chaosmonkey","slug":"failed-to-close-response-body-of-s-v","errorCode":null,"errorMessage":"failed to close response body of %s: %v","messagePattern":"failed to close response body of (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"spinnaker/spinnaker.go","lineNumber":441,"sourceCode":"\t\tlog.Println(url)\n\t\tlog.Println(string(body))\n\t\tlog.Fatalln(err)\n\t}\n\n\treturn m\n}\n\n// asgs returns a slice of autoscaling groups associated with the given cluster\nfunc (s Spinnaker) asgs(appName, account, clusterName string) (result []spinnakerServerGroup, err error) {\n\turl := s.serverGroupsURL(appName, account, clusterName)\n\tresp, err := s.client.Get(url)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to retrieve server groups url (%s): %v\", url, err)\n\t}\n\n\tdefer func() {\n\t\tif cerr := resp.Body.Close(); cerr != nil && err == nil {\n\t\t\terr = fmt.Errorf(\"failed to close response body of %s: %v\", url, err)\n\t\t}\n\t}()\n\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read body of server groups url (%s): body: '%s': %v\", url, string(body), err)\n\t}\n\n\t// Example:\n\t/*\n\t\t[\n\t\t  {\n\t\t    \"name\": \"abc-prod-v016\",\n\t\t    \"region\": \"us-east-1\",\n\t\t    \"zones\": [\n\t\t      \"us-east-1c\",\n\t\t      \"us-east-1d\",\n\t\t      \"us-east-1e\"","sourceCodeStart":423,"sourceCodeEnd":459,"githubUrl":"https://github.com/Netflix/chaosmonkey/blob/eaa28fb761c0ebe8644d1333e5d164e9cc3071e9/spinnaker/spinnaker.go#L423-L459","documentation":"Returned from a deferred close in Spinnaker.asgs when resp.Body.Close fails after a successful GET of the server-groups URL; it only overwrites err if the request otherwise succeeded, signaling the response body could not be cleanly released.","triggerScenarios":"Thrown at spinnaker/spinnaker.go:441 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Treat the close error as non-fatal: log it instead of replacing the already-obtained result","Check whether the body was fully consumed before closing; unconsumed bodies cause close failures","Reuse HTTP connections via keep-alive so close/return-to-pool errors surface early"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}