Netflix/chaosmonkey · error

could not parse body of %s as json, body: %s, error

Error message

could not parse body of %s as json, body: %s, error

What it means

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.

Source

Thrown at spinnaker/spinnaker.go:197

	defer func() {
		if cerr := resp.Body.Close(); cerr != nil && err == nil {
			err = errors.Wrapf(err, "failed to close response body from %s", url)
		}
	}()

	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return "", errors.Wrapf(err, "failed to read body from url %s", url)
	}

	var info struct {
		AccountID string `json:"accountId"`
		Error     string `json:"error"`
	}

	err = json.Unmarshal(body, &info)
	if err != nil {
		return "", errors.Wrapf(err, "could not parse body of %s as json, body: %s, error", url, body)
	}

	if resp.StatusCode != http.StatusOK {
		if info.Error == "" {
			return "", errors.Errorf("%s returned unexpected status code: %d, body: %s", url, resp.StatusCode, body)
		}

		return "", errors.New(info.Error)
	}

	// Some backends may not have associated account ids
	if info.AccountID == "" {
		return s.alternateAccountID(name)
	}

	return info.AccountID, nil

}

View on GitHub (pinned to eaa28fb761)

Solutions

  1. Inspect the logged body to identify what Spinnaker returned (auth page, proxy error, changed schema)
  2. Verify endpoint and credentials are correct so the real JSON API responds
  3. Adapt the unmarshal target if the Spinnaker API schema changed
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at spinnaker/spinnaker.go:197 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Netflix/chaosmonkey@eaa28fb761 (2026-09-03). Data as JSON: /api/errors/4131cbd73e04cc88. Report an issue: GitHub.