From e1f22baceb0ecb1864ba0eb26eddb7c8fff97d53 Mon Sep 17 00:00:00 2001 From: Felix Bernhard Date: Thu, 4 Sep 2025 18:10:38 +0200 Subject: [PATCH 1/6] remove `max_breadcrumbs` range validation --- src/Options.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/Options.php b/src/Options.php index ea5e04787..aaaf022e4 100644 --- a/src/Options.php +++ b/src/Options.php @@ -1336,7 +1336,6 @@ private function configureOptions(OptionsResolver $resolver): void $resolver->setAllowedValues('max_request_body_size', ['none', 'never', 'small', 'medium', 'always']); $resolver->setAllowedValues('dsn', \Closure::fromCallable([$this, 'validateDsnOption'])); - $resolver->setAllowedValues('max_breadcrumbs', \Closure::fromCallable([$this, 'validateMaxBreadcrumbsOptions'])); $resolver->setAllowedValues('class_serializers', \Closure::fromCallable([$this, 'validateClassSerializersOption'])); $resolver->setAllowedValues('context_lines', \Closure::fromCallable([$this, 'validateContextLinesOption'])); @@ -1456,16 +1455,6 @@ private function validateDsnOption($dsn): bool } } - /** - * Validates if the value of the max_breadcrumbs option is in range. - * - * @param int $value The value to validate - */ - private function validateMaxBreadcrumbsOptions(int $value): bool - { - return $value >= 0 && $value <= self::DEFAULT_MAX_BREADCRUMBS; - } - /** * Validates that the values passed to the `class_serializers` option are valid. * From b508fa0f7cbc0583deb4d38baf8e1e3f727e24ac Mon Sep 17 00:00:00 2001 From: Felix Bernhard Date: Thu, 4 Sep 2025 18:13:16 +0200 Subject: [PATCH 2/6] adjust tests to allow for higher max_breadcrumbs values --- tests/OptionsTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/OptionsTest.php b/tests/OptionsTest.php index 4192781a0..e1438ae2c 100644 --- a/tests/OptionsTest.php +++ b/tests/OptionsTest.php @@ -582,11 +582,10 @@ public function testMaxBreadcrumbsOptionIsValidatedCorrectly(bool $isValid, $val public static function maxBreadcrumbsOptionIsValidatedCorrectlyDataProvider(): array { return [ - [false, -1], [true, 0], [true, 1], [true, Options::DEFAULT_MAX_BREADCRUMBS], - [false, Options::DEFAULT_MAX_BREADCRUMBS + 1], + [true, Options::DEFAULT_MAX_BREADCRUMBS + 1], [false, 'string'], [false, '1'], ]; From 42ec84651b42c2152721a98c0914535ca5d00d11 Mon Sep 17 00:00:00 2001 From: Felix Bernhard Date: Thu, 11 Sep 2025 13:13:42 +0200 Subject: [PATCH 3/6] add limits to integer/float options --- src/Options.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Options.php b/src/Options.php index aaaf022e4..145b0ec96 100644 --- a/src/Options.php +++ b/src/Options.php @@ -1338,6 +1338,15 @@ private function configureOptions(OptionsResolver $resolver): void $resolver->setAllowedValues('dsn', \Closure::fromCallable([$this, 'validateDsnOption'])); $resolver->setAllowedValues('class_serializers', \Closure::fromCallable([$this, 'validateClassSerializersOption'])); $resolver->setAllowedValues('context_lines', \Closure::fromCallable([$this, 'validateContextLinesOption'])); + + $resolver->setAllowedValues('sample_rate', fn ($value) => ($value >= 0 && $value <= 1)); + $resolver->setAllowedValues('traces_sample_rate', fn ($value) => ($value >= 0 && $value <= 1)); + $resolver->setAllowedValues('profiles_sample_rate', fn ($value) => ($value >= 0 && $value <= 1)); + $resolver->setAllowedValues('context_lines', fn ($value) => ($value >= 0)); + $resolver->setAllowedValues('max_breadcrumbs', fn ($value) => ($value >= 0)); + $resolver->setAllowedValues('max_value_length', fn ($value) => ($value >= 0)); + $resolver->setAllowedValues('http_connect_timeout', fn ($value) => ($value >= 0)); + $resolver->setAllowedValues('http_timeout', fn ($value) => ($value >= 0)); $resolver->setNormalizer('dsn', \Closure::fromCallable([$this, 'normalizeDsnOption'])); From f10bbf6b8e463c358aeb78f262d71711933281da Mon Sep 17 00:00:00 2001 From: Felix Bernhard Date: Thu, 11 Sep 2025 13:15:22 +0200 Subject: [PATCH 4/6] re-add `max_breadcrumbs` lower limit test case --- tests/OptionsTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/OptionsTest.php b/tests/OptionsTest.php index e1438ae2c..4bc7c7fa4 100644 --- a/tests/OptionsTest.php +++ b/tests/OptionsTest.php @@ -582,6 +582,7 @@ public function testMaxBreadcrumbsOptionIsValidatedCorrectly(bool $isValid, $val public static function maxBreadcrumbsOptionIsValidatedCorrectlyDataProvider(): array { return [ + [false, -1], [true, 0], [true, 1], [true, Options::DEFAULT_MAX_BREADCRUMBS], From 0d513ad1879e02cdb32bb275b2d51d7700670199 Mon Sep 17 00:00:00 2001 From: Felix Bernhard Date: Thu, 11 Sep 2025 13:23:15 +0200 Subject: [PATCH 5/6] remove duplicated `context_line` validator Using `$value >= 0` will also work with `null` values --- src/Options.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/Options.php b/src/Options.php index 145b0ec96..7ed8fa1c3 100644 --- a/src/Options.php +++ b/src/Options.php @@ -1337,7 +1337,6 @@ private function configureOptions(OptionsResolver $resolver): void $resolver->setAllowedValues('max_request_body_size', ['none', 'never', 'small', 'medium', 'always']); $resolver->setAllowedValues('dsn', \Closure::fromCallable([$this, 'validateDsnOption'])); $resolver->setAllowedValues('class_serializers', \Closure::fromCallable([$this, 'validateClassSerializersOption'])); - $resolver->setAllowedValues('context_lines', \Closure::fromCallable([$this, 'validateContextLinesOption'])); $resolver->setAllowedValues('sample_rate', fn ($value) => ($value >= 0 && $value <= 1)); $resolver->setAllowedValues('traces_sample_rate', fn ($value) => ($value >= 0 && $value <= 1)); @@ -1479,14 +1478,4 @@ private function validateClassSerializersOption(array $serializers): bool return true; } - - /** - * Validates that the value passed to the "context_lines" option is valid. - * - * @param int|null $contextLines The value to validate - */ - private function validateContextLinesOption(?int $contextLines): bool - { - return $contextLines === null || $contextLines >= 0; - } } From aa45d2b22c3f137a95ffb61282d9c6dc6843cd0f Mon Sep 17 00:00:00 2001 From: Felix Bernhard Date: Thu, 11 Sep 2025 14:43:11 +0200 Subject: [PATCH 6/6] revert unrelated changes, keep upper limit change --- src/Options.php | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/Options.php b/src/Options.php index 7ed8fa1c3..28093ed6e 100644 --- a/src/Options.php +++ b/src/Options.php @@ -1336,16 +1336,9 @@ private function configureOptions(OptionsResolver $resolver): void $resolver->setAllowedValues('max_request_body_size', ['none', 'never', 'small', 'medium', 'always']); $resolver->setAllowedValues('dsn', \Closure::fromCallable([$this, 'validateDsnOption'])); + $resolver->setAllowedValues('max_breadcrumbs', \Closure::fromCallable([$this, 'validateMaxBreadcrumbsOptions'])); $resolver->setAllowedValues('class_serializers', \Closure::fromCallable([$this, 'validateClassSerializersOption'])); - - $resolver->setAllowedValues('sample_rate', fn ($value) => ($value >= 0 && $value <= 1)); - $resolver->setAllowedValues('traces_sample_rate', fn ($value) => ($value >= 0 && $value <= 1)); - $resolver->setAllowedValues('profiles_sample_rate', fn ($value) => ($value >= 0 && $value <= 1)); - $resolver->setAllowedValues('context_lines', fn ($value) => ($value >= 0)); - $resolver->setAllowedValues('max_breadcrumbs', fn ($value) => ($value >= 0)); - $resolver->setAllowedValues('max_value_length', fn ($value) => ($value >= 0)); - $resolver->setAllowedValues('http_connect_timeout', fn ($value) => ($value >= 0)); - $resolver->setAllowedValues('http_timeout', fn ($value) => ($value >= 0)); + $resolver->setAllowedValues('context_lines', \Closure::fromCallable([$this, 'validateContextLinesOption'])); $resolver->setNormalizer('dsn', \Closure::fromCallable([$this, 'normalizeDsnOption'])); @@ -1463,6 +1456,16 @@ private function validateDsnOption($dsn): bool } } + /** + * Validates if the value of the max_breadcrumbs option is valid. + * + * @param int $value The value to validate + */ + private function validateMaxBreadcrumbsOptions(int $value): bool + { + return $value >= 0; + } + /** * Validates that the values passed to the `class_serializers` option are valid. * @@ -1478,4 +1481,14 @@ private function validateClassSerializersOption(array $serializers): bool return true; } + + /** + * Validates that the value passed to the "context_lines" option is valid. + * + * @param int|null $contextLines The value to validate + */ + private function validateContextLinesOption(?int $contextLines): bool + { + return $contextLines === null || $contextLines >= 0; + } }