{"record":{"id":"e82cb9dd9e317372","repo":"Netflix/chaosmonkey","slug":"attributes-chaosmonkey-meantimebetweenkillsinworkd","errorCode":null,"errorMessage":"attributes.chaosMonkey.meanTimeBetweenKillsInWorkDays missing","messagePattern":"attributes\\.chaosMonkey\\.meanTimeBetweenKillsInWorkDays missing","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"spinnaker/fromjson.go","lineNumber":118,"sourceCode":"\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\n\tif *cm.Enabled && (*cm.MeanTimeBetweenKillsInWorkDays <= 0) {\n\t\treturn nil, fmt.Errorf(\"invalid attributes.chaosMonkey.meanTimeBetweenKillsInWorkDays: %d\", cm.MeanTimeBetweenKillsInWorkDays)\n\t}\n\n\tgrouping := chaosmonkey.Cluster\n\n\tswitch cm.Grouping {\n\tcase \"app\":\n\t\tgrouping = chaosmonkey.App\n\tcase \"stack\":\n\t\tgrouping = chaosmonkey.Stack\n\tcase \"cluster\":","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/Netflix/chaosmonkey/blob/eaa28fb761c0ebe8644d1333e5d164e9cc3071e9/spinnaker/fromjson.go#L100-L136","documentation":"When chaos monkey is enabled for an app, fromJSON requires attributes.chaosMonkey.meanTimeBetweenKillsInWorkDays to be present. The comment in the source notes that if enabled is false it is acceptable for this field to be missing; only an enabled config without it fails.","triggerScenarios":"Calling spinnaker.Get on a payload with chaosMonkey.enabled == true but no meanTimeBetweenKillsInWorkDays key (or null).","commonSituations":"Manually enabling chaos monkey in Spinnaker attributes without setting the mean interval; a UI/script writing enabled=true but leaving the schedule fields empty.","solutions":["Add a positive integer meanTimeBetweenKillsInWorkDays to attributes.chaosMonkey","Re-enroll the app through the chaos monkey configuration flow which populates all required fields","If chaos monkey is not actually wanted, set enabled=false so the missing field is tolerated"],"exampleFix":"// before\n\"chaosMonkey\": {\"enabled\": true, \"minTimeBetweenKillsInWorkDays\": 1}\n// after\n\"chaosMonkey\": {\"enabled\": true, \"meanTimeBetweenKillsInWorkDays\": 5, \"minTimeBetweenKillsInWorkDays\": 1}","handlingStrategy":"validation","validationCode":"var cm struct {\n    Enabled                    *bool `json:\"enabled\"`\n    MeanTimeBetweenKillsInWorkDays *int `json:\"meanTimeBetweenKillsInWorkDays\"`\n}\njson.Unmarshal(cmRaw, &cm)\nif cm.Enabled != nil && *cm.Enabled && cm.MeanTimeBetweenKillsInWorkDays == nil {\n    return errors.New(\"meanTimeBetweenKillsInWorkDays required when enabled\")\n}","typeGuard":"func hasMeanInterval(cmRaw []byte) bool {\n    var p struct {\n        Enabled *bool `json:\"enabled\"`\n        Mean    *int  `json:\"meanTimeBetweenKillsInWorkDays\"`\n    }\n    return json.Unmarshal(cmRaw, &p) == nil && (p.Enabled == nil || !*p.Enabled || p.Mean != nil)\n}","tryCatchPattern":"cfg, err := sp.Get(app)\nif err != nil {\n    if strings.Contains(err.Error(), \"meanTimeBetweenKillsInWorkDays missing\") {\n        return fmt.Errorf(\"app %s: enabled chaos monkey lacks mean interval: %w\", app, err)\n    }\n    return err\n}","preventionTips":["Keep mean and min intervals set together when enabling chaos monkey","Validate required schedule fields in any tooling that writes app attributes","Re-check configs after migrating from older chaos monkey versions"],"tags":["go","json","spinnaker","missing-field","config-validation"],"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"}