Skip to content

[FrameworkBundle] enable detailed error messages by default when debug enabled #57804

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
Aug 13, 2024
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
1 change: 1 addition & 0 deletions src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CHANGELOG
invokable Kernel class, and register `FrameworkBundle` by default when the `bundles.php` file is missing
* [BC BREAK] The `secrets:decrypt-to-local` command terminates with a non-zero exit code when a secret could not be read
* Deprecate making `cache.app` adapter taggable, use the `cache.app.taggable` adapter instead
* Enable `json_decode_detailed_errors` in the default serializer context in debug mode by default when `seld/jsonlint` is installed

7.1
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,10 @@ private function addSerializerSection(ArrayNodeDefinition $rootNode, callable $e
->prototype('variable')->end()
->end()
->end()
->validate()
->ifTrue(fn ($v) => $this->debug && class_exists(JsonParser::class) && !isset($v['default_context'][JsonDecode::DETAILED_ERROR_MESSAGES]))
->then(function ($v) { $v['default_context'][JsonDecode::DETAILED_ERROR_MESSAGES] = true; return $v; })
->end()
->end()
->end()
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,30 @@ public function testScopedHttpClientsInheritRateLimiterAndRetryFailedConfigurati
$this->assertSame(999, $scopedClients['qux']['retry_failed']['delay']);
}

public function testSerializerJsonDetailedErrorMessagesEnabledByDefaultWithDebugEnabled()
{
$processor = new Processor();
$config = $processor->processConfiguration(new Configuration(true), [
[
'serializer' => null,
],
]);

$this->assertSame([JsonDecode::DETAILED_ERROR_MESSAGES => true], $config['serializer']['default_context'] ?? []);
}

public function testSerializerJsonDetailedErrorMessagesNotSetByDefaultWithDebugDisabled()
{
$processor = new Processor();
$config = $processor->processConfiguration(new Configuration(false), [
[
'serializer' => null,
],
]);

$this->assertSame([], $config['serializer']['default_context'] ?? []);
}

protected static function getBundleDefaultConfig()
{
return [
Expand Down