First of all thank you very much for your work on this amazing application :D
Problem
The application crashes or misbehaves when optional environment variables are absent. When using Helm to deploy the application in Kubernetes, empty strings are not injected properly leading to missing env vars errors:
For example:
// value in helm chart
env:
- name: GOOGLE_TRACKING_ID
value: ""
- name: RECAPTCHA_SITE_KEY
value: ""
// injected in container
env:
- name: GOOGLE_TRACKING_ID
- name: RECAPTCHA_SITE_KEY
I solved the issue by injecting placeholder values (e.g. a dash "-") for every optional variable, to keep the app from failing.
Setting some of the env vars to "-" silences the crash, but it is fragile:
- For example LICENSE_KEY needs to be empty, the app errors when a placeholder is present.
- The application may interpret
"-" as a real value rather than "not configured", leading to subtle bugs (e.g. passing "-" as a Google Tracking ID or reCAPTCHA key).
- It is undocumented behaviour that operators have to discover by trial and error.
- It makes it impossible to cleanly distinguish between "not configured" and "misconfigured".
Expected behaviour
The application should not error on missing optional environment variables or there should be a well documented sentinel value.
Suggested fix
Add a guard in the application code before reading each optional variable, for example:
const trackingId = process.env.GOOGLE_TRACKING_ID;
if (trackingId && trackingId !== "") {
// initialise analytics
}
Alternatively, document an official sentinel value (e.g. "disabled" or "-") and handle it consistently in every place the variable is consumed.
First of all thank you very much for your work on this amazing application :D
Problem
The application crashes or misbehaves when optional environment variables are absent. When using Helm to deploy the application in Kubernetes, empty strings are not injected properly leading to missing env vars errors:
For example:
I solved the issue by injecting placeholder values (e.g. a dash
"-") for every optional variable, to keep the app from failing.Setting some of the env vars to
"-"silences the crash, but it is fragile:"-"as a real value rather than "not configured", leading to subtle bugs (e.g. passing"-"as a Google Tracking ID or reCAPTCHA key).Expected behaviour
The application should not error on missing optional environment variables or there should be a well documented sentinel value.
Suggested fix
Add a guard in the application code before reading each optional variable, for example:
Alternatively, document an official sentinel value (e.g.
"disabled"or"-") and handle it consistently in every place the variable is consumed.