Closed jtuttle closed 3 years ago
I know this is a feature since it's mentioned in the README but I think it might be better to remove the auto-parsing of comma-separated strings. Either that or have some way to specify the type you're expecting. Or maybe infer it from the default value?
Or maybe infer it from the default value?
I like it. Sounds like a good option to reduce breaking changes in the existing configs.
Will try to play with it next week.
What did you do?
When loading a config value that's supposed to be a list through an environment variable, the type of the parsed variable differs based on the number of elements in the list (zero/one vs many). That is:
MY_LIST=one
is parsed as a stringMY_LIST=one,two,three
is parsed as a listThis can be tricky to handle in the code that consumes the configuration value. For example, if trying to write a validation in the
on_load
method of a configuration class, you have to make sure it handles both types appropriately (or converts one to the other).What did you expect to happen?
An environment variable with a comma-separated list is parsed as a string.
What actually happened?
An environment variable with a comma-separated list is parsed as a list.
Additional context
Environment
Ruby Version: Ruby 2.5.8p224
Framework Version (Rails, whatever): Rails 5.2.6
Anyway Config Version: 2.1.0