Netflix/chaosmonkey · error

%s returned unexpected status code: %d, body: %s

Error message

%s returned unexpected status code: %d, body: %s

What it means

Returned by Spinnaker.AccountID when the account-URL response has a non-200 status and Spinnaker's error field is empty, so only the status code and raw body are available to explain the failed account lookup.

Source

Thrown at spinnaker/spinnaker.go:202

	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

}

// alternateAccountID returns an account ID for accounts that don't have their
// own ids.
func (s Spinnaker) alternateAccountID(name string) (string, error) {

View on GitHub (pinned to eaa28fb761)

Solutions

  1. Inspect the body for the real cause (often auth failure or unknown account)
  2. Verify the account name exists in Spinnaker
  3. Check API credentials and endpoint configuration
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at spinnaker/spinnaker.go:202 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/8dca70a5499c4987. Report an issue: GitHub.