kscalelabs / store

K-Scale Labs store
https://robolist.xyz
MIT License
6 stars 4 forks source link

Bug: env variable interpolation cannot be relied upon for default values #151

Open EtcetFelix opened 2 weeks ago

EtcetFelix commented 2 weeks ago

While debugging an error related to sending the email for user registration, I encountered an issue with the config loading. For context, I did not export or set the env var ROBOLIST_REDIS_HOST as I did not think it to be necessary since it is set to a default value in RedisSettings. Main Issue The output of settings.redis.host is an empty string, leading to the backend server not being able to connect to Redis. I believe the problem is with the omegaconf library, and I've opened an issue about it on their repo, which you may view in more detail here: Link to issue Image of issue: Screenshot 2024-06-23 095543

The current best workaround is to explicitly set the environment variable in .env: ROBOLIST_REDIS_HOST=127.0.0.1 Other areas using interpolation are all the environment variables related to the email settings, so the email functionality may be affected as well without setting them, though I haven't tested that yet. I recommend explicitly setting every environment variable, and updating the contributing.md page to reflect that for now, as this likely isn't an important enough problem to fix for now.

This, however, brings up the question of why use lazy loading when pulling config settings? I suppose a good reason I can think of is for the ability to change the Redis and email settings without having to reload the fast api server in production. But there might be other reasons to lazy load that I'm not thinking of. Like I said, likely not important to fix, but I am curious.

OmegaConf version: 2.3.0 Python version: Python 3.11.9 Operating system: Ubuntu 22.04.4 LTS