Skip to content

Conversation

@sanderjongsma
Copy link

@sanderjongsma sanderjongsma commented Jan 22, 2025

Summary
I noticed some weird behavior with the config. When you try to override in the backend by enabling sentry/environment/enabled and then disable it, sentry is just always disabled, like described here: #128 so I fixed it by just checking if it is enabled or not and if it is not it just uses the deployment-config. Also for the additional settings, because the log_level was overridden by the setting, because it is a source model it always has a value when saved. Now the overridden values are only used when sentry/environment/enabled flag is true.

I also saw this PR #144 which is great, but also adds another setting and in my opinion the enabled setting can just be used instead of an extra override setting. So basically this PR also does this, and indeed the try catches are not needed.

I deliberately used a simple if/else to make it more readable, it could be fancier, but I think a readable solution is better here.

Result

Deployment-config is always leading for enabling the service. But when backend config is used settings can be overridden only if sentry/environment/enabled is true, in that case backend config is used over deployment-config. When a setting like DSN is not filled in de backend config, it just falls back to the deployment config

Checklist

  • I've ran composer run codestyle
  • I've ran composer run phpstan

@sanderjongsma sanderjongsma force-pushed the only-use-config-if-enabled-in-config branch from f07ab72 to f636f3f Compare January 22, 2025 11:31
Copy link
Member

@indykoning indykoning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's looking simpler than the referenced PR 🙂
One thing i'd like to ensure and then i'll be more than happy to merge!

try {
$this->config[$storeId]['enabled'] = $this->scopeConfig->getValue('sentry/environment/enabled', ScopeInterface::SCOPE_STORE)
?? $this->deploymentConfig->get('sentry') !== null;
} catch (TableNotFoundException|FileSystemException|RuntimeException $e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does isSetFlag already handle these exceptions?
Could you test that out using the instructions here: #125 (comment)

So, setting a different nonexistent database connection and running magerun2 db:info

@indykoning
Copy link
Member

indykoning commented Jun 6, 2025

Seems like this has been fixed by the addition of canRestore="1" in #155 released in 3.9.0

@indykoning indykoning closed this Jun 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants