Project

General

Profile

Bug #10282

Updated by Tom Clegg over 7 years ago

Currently, if a configuration key is misspelled or misplaced in a configuration file, it is silently ignored. 

 Programs that read configuration files should print an error message and exit non-zero when this happens, to avoid running services with configuration different than intended. 

 There is a "Go feature in the works":https://github.com/golang/go/issues/15314 that would be helpful. Even with that, we'd still need our YAML library to expose DisallowUnknownFields() -- either that, or convert YAML → @map[string]interface{}@ → JSON and then load the resulting JSON to the real struct using DisallowUnknownFields(). 

 If we don't want to wait, we could detect invalid keys by comparing site config to example config (but do not read the example config from /etc at runtime -- rather, build the example config into the Go binary). Load both configs into a @map[string]interface{}@, then do a recursive "A's keys are a subset of B's keys" test. 

Back