{"record":{"id":"edd423806f44babe","repo":"Netflix/chaosmonkey","slug":"non-string-in-v","errorCode":null,"errorMessage":"non-string in %v","messagePattern":"non-string in (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/monkey.go","lineNumber":254,"sourceCode":"}\n\n// Accounts return a list of accounts where Choas Monkey is enabled\nfunc (m *Monkey) Accounts() ([]string, error) {\n\terr := m.readRemoteConfig()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn m.getStringSlice(param.Accounts)\n}\n\n// toStrings converts a slice of interfaces to a slice of strings\nfunc toStrings(values []interface{}) ([]string, error) {\n\tresult := make([]string, len(values))\n\tfor i, x := range values {\n\t\tx, valid := x.(string)\n\t\tif !valid {\n\t\t\treturn nil, errors.Errorf(\"non-string in %v\", values)\n\t\t}\n\t\tresult[i] = x\n\t}\n\treturn result, nil\n}\n\n// StartHour (o'clock) is when Chaos\n// Monkey starts terminating this value is in [0,23] This is time-zone\n// dependent, see the Location method\nfunc (m *Monkey) StartHour() int { return m.v.GetInt(param.StartHour) }\n\n// EndHour (o'clock) is the time after which Chaos Monkey will\n// not terminate instances.\n// this value is in [0,23]\n// This is time-zone dependent, see the Location method\nfunc (m *Monkey) EndHour() int {\n\treturn m.v.GetInt(param.EndHour)\n}","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/Netflix/chaosmonkey/blob/eaa28fb761c0ebe8644d1333e5d164e9cc3071e9/config/monkey.go#L236-L272","documentation":"Type guard in toStrings: while converting a config list to []string, an element was not a string (e.g. a TOML integer or boolean inside the accounts/trackers list), so the whole conversion aborts with the offending list included.","triggerScenarios":"Calling getStringSlice for a config key whose value mixes types, e.g. [\"app1\", 42] or a TOML array with non-string entries.","commonSituations":"Config arrays like team emails or app lists where someone wrote an unquoted number/bool; viper returning heterogeneous []interface{} from YAML/JSON.","solutions":["Quote every element in the config array as a string","Check the printed %v values to find the non-string element","Coerce/normalize values (e.g. strconv) if the config legitimately holds numbers","Add a validation step when the config is written, not just read"],"exampleFix":"// before\nteam = [alice, 42, bob]\n// after\nteam = [\"alice\", \"42\", \"bob\"]","handlingStrategy":"validation","validationCode":"// before calling getStringSlice, ensure all array entries are quoted strings in TOML:\n// team = [\"alice\", \"bob\"]  — not  team = [alice, bob]\n// or sanitize:\nfor _, v := range raw.([]interface{}) {\n    if _, ok := v.(string); !ok {\n        return fmt.Errorf(\"config array contains non-string: %v\", v)\n    }\n}","typeGuard":"func allStrings(values []interface{}) bool {\n    for _, v := range values {\n        if _, ok := v.(string); !ok {\n            return false\n        }\n    }\n    return true\n}","tryCatchPattern":"apps, err := cfg.getStringSlice(\"apps\")\nif err != nil {\n    log.Printf(\"fix the config array, all entries must be quoted strings: %v\", err)\n    return err\n}","preventionTips":["Quote every element in config arrays","Validate config values in CI","Prefer homogeneous typed arrays","Catch this at config-write time, not read time"],"tags":["config","validation","type-mismatch"],"backgroundTag":"config-type-mismatch","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"}