bugsnag-symfony
bugsnag-symfony copied to clipboard
Defaulting to ENV vars during container build is problematic
First off, this bundle has come a long way and I really like it now, great job, and thank you!
One snag I ran into though:
Expected behavior
According to the documentation I can configure this bundle via ENV vars, specifically, setting BUGSNAG_API_KEY
– the idea of ENV vars being that I can change their values during deploy time to produce different runtime behavior.
Observed behavior
However, by default ENV vars only end up as a default-values to the container build step, and are consequently frozen into the container as resolved value. A change to ENV vars will not affect a change to the runtime configuration, without rebuilding the container. See: https://github.com/bugsnag/bugsnag-symfony/blob/master/DependencyInjection/Configuration.php#L26
Steps to reproduce
- Warm the cache (build container) while providing
BUGSNAG_API_KEY
via ENV var. - Start a webserver hosting the bundle with a different ENV setting.
- Trigger error report & observe it going to the build-time account. Alternatively, look into the cached container and find frozen resolved value.
Version
1.5.0
Additional information
By explicitly specifying the api_key
via ENV var, the bundle remains configurable at runtime:
bugsnag:
api_key: "%env(BUGSNAG_API_KEY)%"
My recommendation would be to avoid setting default values via ENV inside the Configuration class and instead require them to be specified inside the bugsnag.yml
config file.
I think this is fair, if environment variables are expected to configure options that should be respected in all environments. What do you think @GrahamCampbell?