Invalid configuration file format produces nice error
jtuttle opened this issue · comments
John Tuttle commented
If a ConjurConfig object is initialized and tries to read an invalid YAML file, it will currently fail with an uncaught exception:
bundler: failed to load command: bin/conjurctl (bin/conjurctl)
/opt/conjur/possum/vendor/bundle/ruby/2.5.0/gems/anyway_config-2.1.0/lib/anyway/utils/deep_merge.rb:8:in `deep_merge!': undefined method `each' for "trusted_proxies":String (NoMethodError)
from /opt/conjur/possum/vendor/bundle/ruby/2.5.0/gems/anyway_config-2.1.0/lib/.rbnext/2.7/anyway/config.rb:322:in `block in load_from_sources'
from /opt/conjur/possum/vendor/bundle/ruby/2.5.0/gems/anyway_config-2.1.0/lib/.rbnext/3.0/anyway/loaders.rb:55:in `each'
...
Add a ConfigLoader class whose job is it to load the ConjurConfig object and catch this exception and provide a better error message. Use this in the places where we instantiate a ConjurConfig object.
Susan Jacobs commented
If you start with our file, it won't be a problem. It's a bit of an edge case - Micah put gibberish into the file.