Netflix/chaosmonkey · error

'attributes' field missing

Error message

'attributes' field missing

What it means

fromJSON parses a Spinnaker pipeline/execution payload and requires a top-level 'attributes' object. If the JSON unmarshals but parsed.Attributes is nil, the payload has no attributes field, so a chaos-monkey AppConfig cannot be derived. The error is returned from fromJSON, which is invoked by spinnaker.Get.

Source

Thrown at spinnaker/fromjson.go:102

//	 	  "whitelist": [
//	 	  	{
//	 	  	"account": "test",
//	 	  	"stack": "*",
//	 	  	"region": "*",
//	 	  	"detail": "*"
//	 	  	}
//	 	  ]
//		  }
func fromJSON(js []byte) (*chaosmonkey.AppConfig, error) {
	parsed := new(parsedJSON)
	err := json.Unmarshal(js, parsed)

	if err != nil {
		return nil, errors.Wrap(err, "json unmarshal failed")
	}

	if parsed.Attributes == nil {
		return nil, errors.New("'attributes' field missing")
	}

	if parsed.Attributes.ChaosMonkey == nil {
		return nil, errors.New("'attributes.chaosMonkey' field missing")
	}

	cm := parsed.Attributes.ChaosMonkey

	if cm.Enabled == nil {
		return nil, errors.New("'attributes.chaosMonkey.enabled' field missing")
	}

	// Check if mean time between kills is missing.
	// If not enabled, it's ok if it's missing
	if *cm.Enabled && cm.MeanTimeBetweenKillsInWorkDays == nil {
		return nil, errors.New("attributes.chaosMonkey.meanTimeBetweenKillsInWorkDays missing")
	}

View on GitHub (pinned to eaa28fb761)

Solutions

  1. Verify the Spinnaker endpoint URL and fetch path used by the Get call return the expected entity with an 'attributes' object
  2. Log the raw response body when this error occurs to confirm what was actually returned
  3. Check Spinnaker authentication (cert/key/user config) — a failed auth often yields a payload without attributes
  4. Confirm the Spinnaker API version still nests chaos monkey config under attributes

Example fix

// before: fetching wrong URL
body := fetch(baseURL + "/pipelines")
// after: fetch the entity endpoint that returns attributes
body := fetch(baseURL + "/applications/myapp/serverGroups")
Defensive patterns

Strategy: validation

Validate before calling

var raw map[string]json.RawMessage
if err := json.Unmarshal(body, &raw); err != nil { return err }
if _, ok := raw["attributes"]; !ok { return errors.New("payload has no attributes field") }

Type guard

func hasAttributes(body []byte) bool {
    var p struct{ Attributes map[string]any `json:"attributes"` }
    return json.Unmarshal(body, &p) == nil && p.Attributes != nil
}

Try / catch

cfg, err := sp.Get(app)
if err != nil {
    if strings.Contains(err.Error(), "'attributes' field missing") {
        log.Printf("non-standard Spinnaker payload for %s: %v", app, err)
        return errUnexpectedPayload
    }
    return err
}

Prevention

When it happens

Trigger: Calling spinnaker.Get (which calls fromJSON) on JSON whose root object lacks an 'attributes' key, e.g. an error response, an empty object {}, or a non-Spinnaker payload.

Common situations: Pointing chaos monkey at the wrong Spinnaker endpoint or path so it receives HTML/JSON error bodies; Spinnaker API version changes that reshape the response; misconfigured authentication causing an error payload to be returned instead of the real entity.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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