{"record":{"id":"4131cbd73e04cc88","repo":"Netflix/chaosmonkey","slug":"could-not-parse-body-of-s-as-json-body-s-erro","errorCode":null,"errorMessage":"could not parse body of %s as json, body: %s, error","messagePattern":"could not parse body of (.+?) as json, body: (.+?), error","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"spinnaker/spinnaker.go","lineNumber":197,"sourceCode":"\tdefer func() {\n\t\tif cerr := resp.Body.Close(); cerr != nil && err == nil {\n\t\t\terr = errors.Wrapf(err, \"failed to close response body from %s\", url)\n\t\t}\n\t}()\n\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn \"\", errors.Wrapf(err, \"failed to read body from url %s\", url)\n\t}\n\n\tvar info struct {\n\t\tAccountID string `json:\"accountId\"`\n\t\tError     string `json:\"error\"`\n\t}\n\n\terr = json.Unmarshal(body, &info)\n\tif err != nil {\n\t\treturn \"\", errors.Wrapf(err, \"could not parse body of %s as json, body: %s, error\", url, body)\n\t}\n\n\tif resp.StatusCode != http.StatusOK {\n\t\tif info.Error == \"\" {\n\t\t\treturn \"\", errors.Errorf(\"%s returned unexpected status code: %d, body: %s\", url, resp.StatusCode, body)\n\t\t}\n\n\t\treturn \"\", errors.New(info.Error)\n\t}\n\n\t// Some backends may not have associated account ids\n\tif info.AccountID == \"\" {\n\t\treturn s.alternateAccountID(name)\n\t}\n\n\treturn info.AccountID, nil\n\n}","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/Netflix/chaosmonkey/blob/eaa28fb761c0ebe8644d1333e5d164e9cc3071e9/spinnaker/spinnaker.go#L179-L215","documentation":"Raised in Spinnaker.AccountID when json.Unmarshal fails on the account-URL response body, meaning Spinnaker returned something other than the expected {accountId, error} JSON object — such as an HTML error page or a differently shaped response.","triggerScenarios":"Thrown at spinnaker/spinnaker.go:197 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the logged body to identify what Spinnaker returned (auth page, proxy error, changed schema)","Verify endpoint and credentials are correct so the real JSON API responds","Adapt the unmarshal target if the Spinnaker API schema changed"],"exampleFix":null,"handlingStrategy":"validation","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"}