{"record":{"id":"62b9ef0f7c07958e","repo":"Netflix/chaosmonkey","slug":"failed-to-parse-config","errorCode":null,"errorMessage":"failed to parse config","messagePattern":"failed to parse config","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/monkey.go","lineNumber":139,"sourceCode":"\n// Defaults returns a Monkey config that just has the default values set\n// it will not load local files or remote ones\nfunc Defaults() *Monkey {\n\tv := &Monkey{v: viper.New()}\n\tv.setDefaults()\n\treturn v\n}\n\n// NewFromReader returns a Monkey config which parses the initial config\n// from a reader. It may load remote if configured to\n// Config file must be in toml format\nfunc NewFromReader(in io.Reader) (*Monkey, error) {\n\tm := &Monkey{v: viper.New()}\n\tm.setDefaults()\n\tm.v.SetConfigType(\"toml\")\n\terr := m.v.ReadConfig(in)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to parse config\")\n\t}\n\n\terr = m.configureRemote()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn m, nil\n\n}\n\n// configureRemote configures viper for a remote provider if the user has\n// specified one\nfunc (m *Monkey) configureRemote() error {\n\tprovider := m.v.GetString(param.DynamicProvider)\n\tendpoint := m.v.GetString(param.DynamicEndpoint)\n\tpath := m.v.GetString(param.DynamicPath)\n","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/Netflix/chaosmonkey/blob/eaa28fb761c0ebe8644d1333e5d164e9cc3071e9/config/monkey.go#L121-L157","documentation":"Fires when viper's ReadConfig cannot parse the TOML config supplied via the io.Reader to NewFromReader. It means the provided config bytes are not valid TOML (syntax error, wrong format, empty input); the wrapped viper error identifies the exact parse problem and location.","triggerScenarios":"Constructing a Monkey from a reader whose content is not valid TOML (bad syntax, duplicate keys, type mismatches).","commonSituations":"Programmatically generated config with formatting bugs, embedded config template with a typo, hand-written test fixtures.","solutions":["Inspect the wrapped error for the TOML parse position","Validate the TOML with a linter before feeding the reader","Fix duplicate keys or invalid value types","Ensure the reader is fully written/closed before parsing"],"exampleFix":"// before\nreader := strings.NewReader(\"key = value\") // missing quotes\nm, err := config.NewFromReader(reader)\n// after\nreader := strings.NewReader(\"key = \\\"value\\\"\")\nm, err := config.NewFromReader(reader)","handlingStrategy":"validation","validationCode":"var probe interface{}\nif err := toml.Unmarshal([]byte(tomlBytes), &probe); err != nil {\n    return fmt.Errorf(\"invalid TOML before parsing: %w\", err)\n}\nm, err := config.NewFromReader(bytes.NewReader(tomlBytes))","typeGuard":null,"tryCatchPattern":"m, err := config.NewFromReader(r)\nif err != nil {\n    log.Printf(\"config parse failed: %v\", errors.Unwrap(err))\n    return err\n}","preventionTips":["Validate generated TOML before feeding the reader","Avoid duplicate keys","Use a TOML library/linter in tests for fixtures","Ensure the reader content is complete before parsing"],"tags":["config","viper","toml","parsing"],"backgroundTag":"invalid-config-file","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"}