From 2deeb9332db2900314d51db12bf4c03d7f597aea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=CC=81s=CC=8C=20Ludvik?= Date: Fri, 29 Nov 2024 10:34:01 +0100 Subject: [PATCH] exception is thrown when invalid json is provided --- .../TransactionalMasterRequestConditionProvider.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Component/HttpFoundation/TransactionalMasterRequestConditionProvider.php b/src/Component/HttpFoundation/TransactionalMasterRequestConditionProvider.php index 31180e21a..ada8d858a 100644 --- a/src/Component/HttpFoundation/TransactionalMasterRequestConditionProvider.php +++ b/src/Component/HttpFoundation/TransactionalMasterRequestConditionProvider.php @@ -9,6 +9,7 @@ use GraphQL\Language\Parser; use Override; use Shopsys\FrameworkBundle\Component\HttpFoundation\TransactionalMasterRequestConditionProviderInterface; +use Shopsys\FrontendApiBundle\Model\Error\InvalidArgumentUserError; use Symfony\Component\HttpKernel\Event\RequestEvent; class TransactionalMasterRequestConditionProvider implements TransactionalMasterRequestConditionProviderInterface @@ -44,6 +45,10 @@ protected function isRequestGraphQlQuery(RequestEvent $requestEvent): bool $source = json_decode($requestContent, true); + if (!is_array($source)) { + throw new InvalidArgumentUserError('Request content is not a valid JSON.'); + } + if (!array_key_exists(static::QUERY_TYPE, $source)) { return false; }