Skip to content

Fix empty or null DSN not disabling Sentry #454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## Unreleased

- Add `kernel.project_dir` to `prefixes` default value to trim paths to the project root (#434)
- Add `kernel.project_dir` to `prefixes` default value to trim paths to the project root (#434)
- Fix `null`, `false` or empty value not disabling Sentry (#454)

## 4.0.1 (2021-01-26)

Expand Down
7 changes: 1 addition & 6 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ public function getConfigTreeBuilder(): TreeBuilder
$rootNode
->children()
->scalarNode('dsn')
->beforeNormalization()
->ifTrue(static function ($value): bool {
return empty($value) || (\is_string($value) && '' === trim($value));
})
->thenUnset()
->end()
->info('If this value is not provided, the SDK will try to read it from the SENTRY_DSN environment variable. If that variable also does not exist, the SDK will just not send any events.')
->end()
->booleanNode('register_error_listener')->defaultTrue()->end()
->arrayNode('options')
Expand Down
10 changes: 0 additions & 10 deletions tests/DependencyInjection/Fixtures/php/empty_dsn.php

This file was deleted.

10 changes: 0 additions & 10 deletions tests/DependencyInjection/Fixtures/xml/empty_dsn.xml

This file was deleted.

2 changes: 0 additions & 2 deletions tests/DependencyInjection/Fixtures/yml/empty_dsn.yml

This file was deleted.

8 changes: 0 additions & 8 deletions tests/DependencyInjection/SentryExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,6 @@ public function testClentIsCreatedFromOptions(): void
$this->assertEquals($methodCalls[4][1][0]->getArgument(0), new Reference('sentry.client.options'));
}

public function testEmptyDsnIsTreatedAsIfItWasUnset(): void
{
$container = $this->createContainerFromFixture('empty_dsn');
$optionsDefinition = $container->getDefinition('sentry.client.options');

$this->assertArrayNotHasKey('dsn', $optionsDefinition->getArgument(0));
}

public function testErrorTypesOptionIsParsedFromStringToIntegerValue(): void
{
$container = $this->createContainerFromFixture('error_types');
Expand Down