sentry-symfony
sentry-symfony copied to clipboard
Precedence order when setting app release
When working with the Symfony SDK I noticed that the app version set in composer.json as below is prioritised over the SENTRT_RELEASE environment variable set in .env file.
{
"type": "project",
"license": "proprietary",
"version": "1.58.1",
"minimum-stability": "stable",
}
The precedence order according to my tests was:
- Release set in config/packages/sentry.yaml
- “Version” tag added to composer.json
- SENTRY_RELEASE environment variable set in .env
Because only the environment variable and sentry.yaml options are documented, I would expect these two to take precedence over all other automatically detected releases. Is this intended behaviour?
I’m using: Sentry Symfony SDK v4.2.9 Composer v2.0.9 Symfony v5.4.8 PHP v7.4.29
Is this intended behaviour?
To be honest, I think we didn't think about this behaviour at all. What's happening is that since the sentry.options.release default value is taken from PrettyVersions::getRootPackageVersion()->getPrettyVersion(), if the version field in the composer.json is available then that value is the one used and no fallback to the env var happens. If you forcefully set the option to %env(SENTRY_RELEASE), it should work. I think that this behaviour may be better documented indeed, and the proper repo to report this is getsentry/sentry-docs
This issue has gone three weeks without activity. In another week, I will close it.
But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!
"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀
@kamilogorek do you think that it would make sense to prefer the environment variable to the version stored in the composer.json? I think that the same question may apply on projects built with the NodeJS SDK, so maybe a decision was already laid out in the past on the expected behaviour
For sentry-cli we use this ordering (from the highest priority):
- Arguments passed directly to the command, eg
sentry-cli --auth-token=foo - Env vars,
SENTRY_AUTH_TOKEN=bar - Dotfiles
- Config files
So yes, I'd prefer env-vars over composer.json