Unable to load optional values from env
Loskir opened this issue · 4 comments
Loskir commented
Steps to reproduce:
- Add an optional value to the schema.
{test: Optional(String)}
- Map it to some env variable in yaml.
test: ${TEST_ENV}
- Set the env, run the file and see that it's undefined.
DEBUG=tconf* TEST_ENV=123 node index.js
tconf loading files from ./config/: default, NODE_ENV, ENV, local +0ms
tconf:file parsing config config/default.yaml +0ms
tconf:env unable to coerce value from env var "test" as type optional +0ms
tconf:file config file config/NODE_ENV.yaml not found +2ms
tconf inspecting environment variables +3ms
tconf:file config file config/local.yaml not found +0ms
{ test: undefined }
Example: https://github.com/Loskir/tconf-test
Loskir commented
Mapped variable also doesn't work
DEBUG=tconf* CONFIG_test=123 node index.js
tconf loading files from ./config/: default, NODE_ENV, ENV, local +0ms
tconf:file parsing config config/default.yaml +0ms
tconf:file config file config/NODE_ENV.yaml not found +1ms
tconf inspecting environment variables +3ms
tconf:env processing env var "CONFIG_test" +0ms
tconf:env retrieving type information from test +0ms
tconf:env coercing value to optional +0ms
tconf:env unable to coerce value from env var "CONFIG_test" as type optional +0ms
tconf:file config file config/local.yaml not found +1ms
{}
codemariner commented
codemariner commented
Hi @Loskir. This has been fixed in release 2.2.2.. You should be able to map environment variables to Optional
types now. Please let me know if you have run into any more problems.
Loskir commented
Thank you!