{"record":{"id":"20c94a11681f1d08","repo":"Netflix/chaosmonkey","slug":"missing-account-field-in-exception","errorCode":null,"errorMessage":"missing account field in exception","messagePattern":"missing account field in exception","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"spinnaker/fromjson.go","lineNumber":160,"sourceCode":"\t\t\treturn nil, errors.Errorf(\"Unknown grouping: %s\", cm.Grouping)\n\t\t}\n\t}\n\n\tvar meanTime int\n\tvar minTime int\n\n\tif cm.MeanTimeBetweenKillsInWorkDays != nil {\n\t\tmeanTime = *cm.MeanTimeBetweenKillsInWorkDays\n\t}\n\n\tif cm.MinTimeBetweenKillsInWorkDays != nil {\n\t\tminTime = *cm.MinTimeBetweenKillsInWorkDays\n\t}\n\n\t// Exceptions must have a non-blank region field\n\tfor _, exception := range cm.Exceptions {\n\t\tif exception.Account == \"\" {\n\t\t\treturn nil, errors.New(\"missing account field in exception\")\n\t\t}\n\n\t\tif exception.Region == \"\" {\n\t\t\treturn nil, errors.New(\"missing region field in exception\")\n\t\t}\n\t}\n\n\tcfg := chaosmonkey.AppConfig{\n\t\tEnabled:                        *cm.Enabled,\n\t\tRegionsAreIndependent:          cm.RegionsAreIndependent,\n\t\tGrouping:                       grouping,\n\t\tMeanTimeBetweenKillsInWorkDays: meanTime,\n\t\tMinTimeBetweenKillsInWorkDays:  minTime,\n\t\tExceptions:                     cm.Exceptions,\n\t\tWhitelist:                      cm.Whitelist,\n\t}\n\n\treturn &cfg, nil","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/Netflix/chaosmonkey/blob/eaa28fb761c0ebe8644d1333e5d164e9cc3071e9/spinnaker/fromjson.go#L142-L178","documentation":"Every entry in attributes.chaosMonkey.exceptions must specify an account. fromJSON iterates the exceptions list and returns this error if any exception's Account field is an empty string, since an exception without an account cannot be matched against Spinnaker deployments.","triggerScenarios":"Calling spinnaker.Get on a payload whose chaosMonkey.exceptions array contains an object like {\"region\":\"us-east-1\"} with no account key (or account: \"\").","commonSituations":"Hand-writing exception entries in the app's Spinnaker attributes; copy-pasting an exception and forgetting to fill in account; tooling emitting partial exception objects.","solutions":["Add the cloud account name to every exception object in attributes.chaosMonkey.exceptions","Remove the incomplete exception entry if it is not needed","Validate the exceptions JSON before saving it to Spinnaker"],"exampleFix":"// before\n\"exceptions\": [{\"region\": \"us-east-1\"}]\n// after\n\"exceptions\": [{\"account\": \"prod-account\", \"region\": \"us-east-1\"}]","handlingStrategy":"validation","validationCode":"var cm struct {\n    Exceptions []struct {\n        Account string `json:\"account\"`\n    } `json:\"exceptions\"`\n}\njson.Unmarshal(cmRaw, &cm)\nfor i, e := range cm.Exceptions {\n    if e.Account == \"\" { return fmt.Errorf(\"exception %d missing account\", i) }\n}","typeGuard":"func exceptionsHaveAccounts(cmRaw []byte) bool {\n    var p struct {\n        Exceptions []struct{ Account string `json:\"account\"` } `json:\"exceptions\"`\n    }\n    if json.Unmarshal(cmRaw, &p) != nil { return false }\n    for _, e := range p.Exceptions { if e.Account == \"\" { return false } }\n    return true\n}","tryCatchPattern":"cfg, err := sp.Get(app)\nif err != nil {\n    if strings.Contains(err.Error(), \"missing account field in exception\") {\n        return fmt.Errorf(\"app %s has malformed exception entries: %w\", app, err)\n    }\n    return err\n}","preventionTips":["Lint the exceptions array before saving it to Spinnaker attributes","Use a shared struct/template when generating exception entries","Review hand-edited configs for required account/region pairs"],"tags":["go","json","spinnaker","missing-field","exceptions"],"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"}