Netflix/chaosmonkey · error
failed to read config file
Error message
failed to read config file
What it means
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.
Source
Thrown at config/monkey.go:109
func Load(configPaths []string) (*Monkey, error) {
m := &Monkey{v: viper.New()}
m.setDefaults()
m.setupEnvVarReader()
for _, dir := range configPaths {
m.v.AddConfigPath(dir)
}
m.v.SetConfigType("toml")
m.v.SetConfigName("chaosmonkey")
err := m.v.ReadInConfig()
// It's ok if the config file doesn't exist, but we want to catch any
// other config-related issues
if err != nil {
if !os.IsNotExist(err) {
return nil, errors.Wrapf(err, "failed to read config file")
}
log.Printf("no config file found, proceeding without one")
}
err = m.configureRemote()
if err != nil {
return nil, err
}
return m, nil
}
// Defaults returns a Monkey config that just has the default values set
// it will not load local files or remote ones
func Defaults() *Monkey {
v := &Monkey{v: viper.New()}
v.setDefaults()
return vView on GitHub (pinned to eaa28fb761)
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
Example fix
// before cfg = monkey.toml schedule_endpoint = "http://..." // after # valid TOML: quote the value and add newline cfg = monkey.toml schedule_endpoint = "http://..."
Defensive patterns
Strategy: validation
Validate before calling
f, err := os.Open(configPath)
if err != nil {
log.Fatalf("config unreadable: %v", err)
}
f.Close()
// optionally pre-validate TOML with a parser before Load Try / catch
m, err := config.Load(path)
if err != nil {
if strings.Contains(err.Error(), "failed to read config file") {
log.Fatalf("fix config at %s: %v", path, errors.Unwrap(err))
}
return err
} Prevention
- 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
When it happens
Trigger: Calling Load (via getConfig) when the config file exists but is unreadable (permissions) or contains syntax errors (invalid TOML).
Common situations: Config file with a TOML typo after an edit, file owned by root with 0600, symlink to a missing target, wrong CONFIG_PATH.
Related errors
- failed to parse config
- failed viper.AddRemoteProvider(provider="%s", endpoint="%s",
- FATAL: no spinnaker endpoint specified in config
- failed to populate schedule: %v
- deploySchedule: could not retrieve local timezone: %v
AI-assisted analysis of Netflix/chaosmonkey@eaa28fb761 (2026-09-03).
Data as JSON: /api/errors/bdcb6fbf5e41cc74.
Report an issue: GitHub.