Skip to content

Commit 8349e99

Browse files
authored
Fix empty or null DSN not disabling Sentry (#454)
1 parent b4ce112 commit 8349e99

File tree

6 files changed

+3
-37
lines changed

6 files changed

+3
-37
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
## Unreleased
44

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

78
## 4.0.1 (2021-01-26)
89

src/DependencyInjection/Configuration.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,7 @@ public function getConfigTreeBuilder(): TreeBuilder
2929
$rootNode
3030
->children()
3131
->scalarNode('dsn')
32-
->beforeNormalization()
33-
->ifTrue(static function ($value): bool {
34-
return empty($value) || (\is_string($value) && '' === trim($value));
35-
})
36-
->thenUnset()
37-
->end()
32+
->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.')
3833
->end()
3934
->booleanNode('register_error_listener')->defaultTrue()->end()
4035
->arrayNode('options')

tests/DependencyInjection/Fixtures/php/empty_dsn.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/DependencyInjection/Fixtures/xml/empty_dsn.xml

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/DependencyInjection/Fixtures/yml/empty_dsn.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/DependencyInjection/SentryExtensionTest.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,6 @@ public function testClentIsCreatedFromOptions(): void
236236
$this->assertEquals($methodCalls[4][1][0]->getArgument(0), new Reference('sentry.client.options'));
237237
}
238238

239-
public function testEmptyDsnIsTreatedAsIfItWasUnset(): void
240-
{
241-
$container = $this->createContainerFromFixture('empty_dsn');
242-
$optionsDefinition = $container->getDefinition('sentry.client.options');
243-
244-
$this->assertArrayNotHasKey('dsn', $optionsDefinition->getArgument(0));
245-
}
246-
247239
public function testErrorTypesOptionIsParsedFromStringToIntegerValue(): void
248240
{
249241
$container = $this->createContainerFromFixture('error_types');

0 commit comments

Comments
 (0)