fisher60 / friendo-bot

A Discord Bot that is just a good Friendo
MIT License
25 stars 23 forks source link

Fix .env loading bugs with special characters #254

Open fisher60 opened 1 year ago

fisher60 commented 1 year ago

Summary

Our environment variables are potentially missing data in prod due to the special character "$" being stripped. We should consider migrating to a different method of loading our .env file in our prod docker deployment to fix this.

For now a quick fix is to wrap environment variables in single quotes to prevent them from being interpreted via bash on linux.

jacobmonck commented 1 year ago

I believe the python-dotenv package will fix this as it parses the dotenv file differently to allow for special characters as seen below.

The syntax of .env files supported by python-dotenv is similar to that of Bash:

# Development settings
DOMAIN=example.org
ADMIN_EMAIL=admin@${DOMAIN}
ROOT_URL=${DOMAIN}/app

If you use variables in values, ensure they are surrounded with { and }, like ${DOMAIN}, as bare variables such as $DOMAIN are not expanded.

here's a link to the pypi site where I found this little snippet https://pypi.org/project/python-dotenv/#getting-started