{"record":{"id":"4294d7ea5da65e98","repo":"Netflix/chaosmonkey","slug":"attributes-chaosmonkey-field-missing","errorCode":null,"errorMessage":"'attributes.chaosMonkey' field missing","messagePattern":"'attributes\\.chaosMonkey' field missing","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"spinnaker/fromjson.go","lineNumber":106,"sourceCode":"//\t \t  \t\"region\": \"*\",\n//\t \t  \t\"detail\": \"*\"\n//\t \t  \t}\n//\t \t  ]\n//\t\t  }\nfunc fromJSON(js []byte) (*chaosmonkey.AppConfig, error) {\n\tparsed := new(parsedJSON)\n\terr := json.Unmarshal(js, parsed)\n\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"json unmarshal failed\")\n\t}\n\n\tif parsed.Attributes == nil {\n\t\treturn nil, errors.New(\"'attributes' field missing\")\n\t}\n\n\tif parsed.Attributes.ChaosMonkey == nil {\n\t\treturn nil, errors.New(\"'attributes.chaosMonkey' field missing\")\n\t}\n\n\tcm := parsed.Attributes.ChaosMonkey\n\n\tif cm.Enabled == nil {\n\t\treturn nil, errors.New(\"'attributes.chaosMonkey.enabled' field missing\")\n\t}\n\n\t// Check if mean time between kills is missing.\n\t// If not enabled, it's ok if it's missing\n\tif *cm.Enabled && cm.MeanTimeBetweenKillsInWorkDays == nil {\n\t\treturn nil, errors.New(\"attributes.chaosMonkey.meanTimeBetweenKillsInWorkDays missing\")\n\t}\n\n\tif *cm.Enabled && cm.MinTimeBetweenKillsInWorkDays == nil {\n\t\treturn nil, errors.New(\"attributes.chaosMonkey.minTimeBetweenKillsInWorkDays missing\")\n\t}\n","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/Netflix/chaosmonkey/blob/eaa28fb761c0ebe8644d1333e5d164e9cc3071e9/spinnaker/fromjson.go#L88-L124","documentation":"fromJSON requires attributes.chaosMonkey to be present inside the Spinnaker payload. When the 'attributes' object exists but its chaosMonkey member is nil, there is no chaos monkey configuration embedded for this application, so fromJSON cannot build an AppConfig and returns this error.","triggerScenarios":"Calling spinnaker.Get for an application whose Spinnaker attributes contain no chaosMonkey sub-object (chaos monkey never enabled/configured for that app in Spinnaker).","commonSituations":"Querying a newly created application that was never enrolled in chaos monkey; the chaosMonkey metadata was deleted from the app's Spinnaker attributes; fetching the wrong application name.","solutions":["Enroll the application in chaos monkey so attributes.chaosMonkey is written to Spinnaker","Treat this error as 'app not enrolled' and skip the app rather than failing","Double-check the application name passed to Get matches the enrolled app"],"exampleFix":"// before\nappConfig, err := sp.Get(appName)\nif err != nil { return err }\n// after\nappConfig, err := sp.Get(appName)\nif errors.Is(err, errNoChaosMonkeyField) || err != nil && strings.Contains(err.Error(), \"attributes.chaosMonkey\") {\n    return nil // app not enrolled; skip\n}","handlingStrategy":"validation","validationCode":"var probe struct {\n    Attributes *struct {\n        ChaosMonkey *json.RawMessage `json:\"chaosMonkey\"`\n    } `json:\"attributes\"`\n}\nif err := json.Unmarshal(body, &probe); err != nil { return err }\nif probe.Attributes == nil || probe.Attributes.ChaosMonkey == nil {\n    return errNotEnrolled // skip app\n}","typeGuard":"func isChaosMonkeyConfigured(body []byte) bool {\n    var p struct {\n        Attributes struct {\n            ChaosMonkey *map[string]any `json:\"chaosMonkey\"`\n        } `json:\"attributes\"`\n    }\n    return json.Unmarshal(body, &p) == nil && p.Attributes.ChaosMonkey != nil\n}","tryCatchPattern":"cfg, err := sp.Get(app)\nif err != nil {\n    if strings.Contains(err.Error(), \"attributes.chaosMonkey' field missing\") {\n        return nil // app not enrolled in chaos monkey; skip\n    }\n    return err\n}","preventionTips":["Maintain a list of enrolled apps and only query those","Treat this error as 'not enrolled' rather than a hard failure in batch jobs","Audit app attributes after Spinnaker upgrades or migrations"],"tags":["go","json","spinnaker","missing-field"],"backgroundTag":"missing-required-argument","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"}