Describe the bug
When using the built in interpolation resolver oc:env with a default value, the resolution is an empty string when the environment variable doesn't exist or is empty.
To Reproduce
I've attached the files to reproduce the issue below but here is the code:
from dataclasses import dataclass, field
from omegaconf import II, OmegaConf
@dataclass
class EnvironmentSettings:
host: str = field(default=II("oc.env:REDIS_HOST,default_host"))
config = OmegaConf.structured(EnvironmentSettings)
print(config)
print(config.host) # Should be 'default_host', but is empty string
print("done")
REDIS_HOST is not set in the environment on purpose.
You can specify a default value to use in case the environment variable is not set.
The expectation is that the output of the interpolation resolution is the default value. In this case, the output of config.host should be the string 'default_host'
Describe the bug When using the built in interpolation resolver
oc:env
with a default value, the resolution is an empty string when the environment variable doesn't exist or is empty.To Reproduce I've attached the files to reproduce the issue below but here is the code:
REDIS_HOST is not set in the environment on purpose.
Zip file with everything related to reproduce the issue: testingOcEnvEmptyDefaultBug.zip
Expected behavior According to the documentation:
The expectation is that the output of the interpolation resolution is the default value. In this case, the output of config.host should be the string 'default_host'
Additional context