{"record":{"id":"bdcb6fbf5e41cc74","repo":"Netflix/chaosmonkey","slug":"failed-to-read-config-file","errorCode":null,"errorMessage":"failed to read config file","messagePattern":"failed to read config file","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/monkey.go","lineNumber":109,"sourceCode":"func Load(configPaths []string) (*Monkey, error) {\n\tm := &Monkey{v: viper.New()}\n\n\tm.setDefaults()\n\tm.setupEnvVarReader()\n\n\tfor _, dir := range configPaths {\n\t\tm.v.AddConfigPath(dir)\n\t}\n\n\tm.v.SetConfigType(\"toml\")\n\tm.v.SetConfigName(\"chaosmonkey\")\n\n\terr := m.v.ReadInConfig()\n\t// It's ok if the config file doesn't exist, but we want to catch any\n\t// other config-related issues\n\tif err != nil {\n\t\tif !os.IsNotExist(err) {\n\t\t\treturn nil, errors.Wrapf(err, \"failed to read config file\")\n\t\t}\n\n\t\tlog.Printf(\"no config file found, proceeding without one\")\n\t}\n\n\terr = m.configureRemote()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn m, nil\n}\n\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","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/Netflix/chaosmonkey/blob/eaa28fb761c0ebe8644d1333e5d164e9cc3071e9/config/monkey.go#L91-L127","documentation":"Raised by config.Load when viper's ReadInConfig fails for a reason other than the file not existing — e.g. malformed TOML or an unreadable file. Missing files are deliberately tolerated and logged, so this error always indicates actual config-file corruption or I/O problems.","triggerScenarios":"Calling Load (via getConfig) when the config file exists but is unreadable (permissions) or contains syntax errors (invalid TOML).","commonSituations":"Config file with a TOML typo after an edit, file owned by root with 0600, symlink to a missing target, wrong CONFIG_PATH.","solutions":["Check the wrapped viper error for the exact line/parse problem","Run the file through a TOML linter/validator","Fix file permissions so the process user can read it","Confirm the config file path env var points to the intended file"],"exampleFix":"// before\ncfg = monkey.toml\nschedule_endpoint = \"http://...\"\n// after\n# valid TOML: quote the value and add newline\ncfg = monkey.toml\nschedule_endpoint = \"http://...\"","handlingStrategy":"validation","validationCode":"f, err := os.Open(configPath)\nif err != nil {\n    log.Fatalf(\"config unreadable: %v\", err)\n}\nf.Close()\n// optionally pre-validate TOML with a parser before Load","typeGuard":null,"tryCatchPattern":"m, err := config.Load(path)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to read config file\") {\n        log.Fatalf(\"fix config at %s: %v\", path, errors.Unwrap(err))\n    }\n    return err\n}","preventionTips":["Lint TOML config in CI before deployment","Check file permissions after edits","Keep a known-good sample config","Validate config at deploy time, not runtime"],"tags":["config","viper","toml"],"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"}