-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Throw descriptive error message for absent .env #1546
Conversation
@edmofro I assigned this to you directly because we were discussing about it the other day, and also I have a question for you related to this |
user: process.env.DB_USER, | ||
password: process.env.DB_PASSWORD, | ||
database: process.env.DB_NAME, | ||
ssl: ['true', undefined].includes(process.env.DB_DISABLE_SSL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So here is a change: we currently set ssl
to null only if DB_DISABLE_SSL
is explicitly set to true
. It seems to me that it should be the other way around: SSL should be disabled by default, and people can turn it on. But let me know if my understanding is wrong.
If this is correct, we may want to rename this to DB_ENABLE_SSL
to make this "opt-in" behaviour clearer.
Also, I couldn't find a .env
file in Last Pass where this was set to a value other than true
, so I'm wondering whether it is used at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's set to false if you are developing locally but want to connect to a remote database. In future, we aim to move the database across to a service like RDS, so we'd also want to use an ssl connection then.
I'd agree with your suggestion of the rename and default
@@ -1,4 +1,4 @@ | |||
DB_DISABLE_SSL= | |||
DB_ENABLE_SSL= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we should include this optional field in the examples or just skip it, I chose to include it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think it's good to include for completeness. Please add a note that the release process needs to include some manual changes to environment variables (the process is somewhat arduous)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add it (by the way I am the release manager this week). Could you explain the process to me in person (or point me to related documentation)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For sure. This is the best documentation so far, but I will take you through it in person and we can add a doc just for that process
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice breaking out two consts, that's much more clear.
Pre-approved with one suggested change
if (config.ssl) { | ||
return; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (config.ssl) { | |
return; | |
} |
If ssl is set, it doesn't guarantee we have the other variables set up correctly (and we still need to)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure about that and actually I should have left a question-comment! Thanks for catching this!
}, | ||
}; | ||
validateEnv(); | ||
// Note: Must use functions to guarantee environment variables have loaded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed this is the case... In previous commits, I removed the comment (and used const
) without a problem, but I was probably lucky
This functionality now fails if functions are not used to retrieve the .env
variables
@edmofro I'm going to merge this into |
Sounds good! |
@edmofro as discussed, it seems that in our current prod/dev instances (and LastPass), the following applies:
Which implies that the presence of Given that we want to be able to connect to a remote DB, we can still retain support for |
Issue #:
[No issue]