sentry-symfony icon indicating copy to clipboard operation
sentry-symfony copied to clipboard

Precedence order when setting app release

Open rodolfoBee opened this issue 3 years ago • 4 comments

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:

  1. Release set in config/packages/sentry.yaml
  2. “Version” tag added to composer.json
  3. 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

rodolfoBee avatar May 05 '22 13:05 rodolfoBee

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

ste93cry avatar May 09 '22 17:05 ste93cry

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 🥀

github-actions[bot] avatar May 31 '22 00:05 github-actions[bot]

@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

ste93cry avatar May 31 '22 16:05 ste93cry

For sentry-cli we use this ordering (from the highest priority):

  1. Arguments passed directly to the command, eg sentry-cli --auth-token=foo
  2. Env vars, SENTRY_AUTH_TOKEN=bar
  3. Dotfiles
  4. Config files

So yes, I'd prefer env-vars over composer.json

kamilogorek avatar May 31 '22 18:05 kamilogorek