Error 500 Internal Server Error

GET http://api.dev.newretail.avp.tech/brands/V/channels/v-digital-retail/videos

Exceptions

App\Security\Voter\BrandSubresourceVoter::voteOnIteratorAggregate(): Argument #1 ($user) must be of type App\Entity\User|App\Entity\Device, null given, called in /usr/src/app/src/Security/Voter/BrandSubresourceVoter.php on line 52

Exception

TypeError

  1. private function normalizeBrandCode(string $code): string
  2. {
  3. return $this->isVolkswagenBrand($code) ? BrandEnum::VOLKSWAGEN->value : $code;
  4. }
  5. public function voteOnIteratorAggregate(User|Device $user, \IteratorAggregate $paginator): int
  6. {
  7. $iterator = $paginator->getIterator();
  8. foreach ($iterator as $brandAware) {
  9. if (!$brandAware instanceof BrandAwareInterface) {
BrandSubresourceVoter->voteOnIteratorAggregate() in src/Security/Voter/BrandSubresourceVoter.php (line 52)
  1. if ($subject instanceof BrandAwareInterface) {
  2. return $this->voteOnBrandAware($user, $subject);
  3. }
  4. if ($subject instanceof \IteratorAggregate) {
  5. return $this->voteOnIteratorAggregate($user, $subject);
  6. }
  7. return VoterInterface::ACCESS_ABSTAIN;
  8. }
  1. ) {
  2. }
  3. public function vote(TokenInterface $token, mixed $subject, array $attributes, ?Vote $vote = null): int
  4. {
  5. $result = $this->voter->vote($token, $subject, $attributes, $vote);
  6. $this->eventDispatcher->dispatch(new VoteEvent($this->voter, $subject, $attributes, $result, $vote->reasons ?? []), 'debug.security.authorization.vote');
  7. return $result;
  8. }
  1. */
  2. private function collectResults(TokenInterface $token, array $attributes, mixed $object, AccessDecision $accessDecision): \Traversable
  3. {
  4. foreach ($this->getVoters($attributes, $object) as $voter) {
  5. $vote = new Vote();
  6. $result = $voter->vote($token, $object, $attributes, $vote);
  7. if (!\is_int($result) || !(self::VALID_VOTES[$result] ?? false)) {
  8. throw new \LogicException(\sprintf('"%s::vote()" must return one of "%s" constants ("ACCESS_GRANTED", "ACCESS_DENIED" or "ACCESS_ABSTAIN"), "%s" returned.', get_debug_type($voter), VoterInterface::class, var_export($result, true)));
  9. }
  1. }
  2. public function decide(\Traversable $results, ?AccessDecision $accessDecision = null): bool
  3. {
  4. $grant = 0;
  5. foreach ($results as $result) {
  6. if (VoterInterface::ACCESS_DENIED === $result) {
  7. return false;
  8. }
  9. if (VoterInterface::ACCESS_GRANTED === $result) {
  1. $this->accessDecisionStack[] = $accessDecision;
  2. $accessDecision->strategy = $this->strategy instanceof \Stringable ? $this->strategy : get_debug_type($this->strategy);
  3. try {
  4. return $accessDecision->isGranted = $this->strategy->decide(
  5. $this->collectResults($token, $attributes, $object, $accessDecision),
  6. $accessDecision,
  7. );
  8. } finally {
  9. array_pop($this->accessDecisionStack);
  1. $accessDecision ??= end($this->accessDecisionStack) ?: new AccessDecision();
  2. $this->accessDecisionStack[] = $accessDecision;
  3. try {
  4. return $accessDecision->isGranted = $this->manager->decide($token, $attributes, $object, $accessDecision, $allowMultipleAttributes);
  5. } finally {
  6. $this->strategy = $accessDecision->strategy;
  7. $currentLog = array_pop($this->currentLog);
  8. if (isset($accessDecision->isGranted)) {
  9. $currentLog['result'] = $accessDecision->isGranted;
  1. }
  2. $accessDecision ??= end($this->accessDecisionStack) ?: new AccessDecision();
  3. $this->accessDecisionStack[] = $accessDecision;
  4. try {
  5. return $accessDecision->isGranted = $this->accessDecisionManager->decide($token, [$attribute], $subject, $accessDecision);
  6. } finally {
  7. array_pop($this->accessDecisionStack);
  8. }
  9. }
  1. final class ExpressionLanguageProvider implements ExpressionFunctionProviderInterface
  2. {
  3. public function getFunctions(): array
  4. {
  5. return [
  6. new ExpressionFunction('is_granted', static fn ($attributes, $object = 'null'): string => \sprintf('$auth_checker->isGranted(%s, %s)', $attributes, $object), static fn (array $variables, $attributes, $object = null) => $variables['auth_checker']->isGranted($attributes, $object)),
  7. ];
  8. }
  9. }
in vendor/symfony/expression-language/Node/FunctionNode.php :: ApiPlatform\Symfony\Security\Core\Authorization\{closure} (line 50)
  1. $arguments = [$values];
  2. foreach ($this->nodes['arguments']->nodes as $node) {
  3. $arguments[] = $node->evaluate($functions, $values);
  4. }
  5. return $functions[$this->attributes['name']]['evaluator'](...$arguments);
  6. }
  7. public function toArray(): array
  8. {
  9. $array = [];
  1. }
  2. public function evaluate(array $functions, array $values): mixed
  3. {
  4. $operator = $this->attributes['operator'];
  5. $left = $this->nodes['left']->evaluate($functions, $values);
  6. if (isset(self::FUNCTIONS[$operator])) {
  7. $right = $this->nodes['right']->evaluate($functions, $values);
  8. return match ($operator) {
  1. /**
  2. * Evaluate an expression.
  3. */
  4. public function evaluate(Expression|string $expression, array $values = []): mixed
  5. {
  6. return $this->parse($expression, array_keys($values))->getNodes()->evaluate($this->functions, $values);
  7. }
  8. /**
  9. * Parses an expression.
  10. *
  1. $token = new NullToken();
  2. }
  3. $variables = array_merge($variables, $this->getVariables($token));
  4. return (bool) $this->expressionLanguage->evaluate($expression, $variables);
  5. }
  6. /**
  7. * @copyright Fabien Potencier <fabien@symfony.com>
  8. *
  1. 'object' => $body,
  2. 'previous_object' => $context['graphql_context']['previous_object'] ?? null,
  3. ];
  4. }
  5. if (!$this->resourceAccessChecker->isGranted($operation->getClass(), $isGranted, $resourceAccessCheckerContext)) {
  6. $operation instanceof GraphQlOperation ? throw new AccessDeniedHttpException($message ?? 'Access Denied.') : throw new AccessDeniedException($message ?? 'Access Denied.');
  7. }
  8. return $body;
  9. }
  1. {
  2. }
  3. public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
  4. {
  5. $body = $this->decorated->provide($operation, $uriVariables, $context);
  6. $request = $context['request'] ?? null;
  7. $operation = $request?->attributes->get('_api_operation') ?? $operation;
  8. $parameters = $operation->getParameters() ?? new Parameters();
  1. // We need request content
  2. if (!$operation instanceof HttpOperation || !($request = $context['request'] ?? null)) {
  3. return $this->decorated?->provide($operation, $uriVariables, $context);
  4. }
  5. $data = $this->decorated ? $this->decorated->provide($operation, $uriVariables, $context) : $request->attributes->get('data');
  6. if (!$operation->canDeserialize() || $context['request']->attributes->has('deserialized')) {
  7. return $data;
  8. }
  1. default:
  2. $isGranted = $operation->getSecurity();
  3. $message = $operation->getSecurityMessage();
  4. }
  5. $body = $this->decorated->provide($operation, $uriVariables, $context);
  6. if (null === $isGranted) {
  7. return $body;
  8. }
  9. // On a GraphQl QueryCollection we want to perform security stage only on the top-level query
  1. {
  2. }
  3. public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
  4. {
  5. $body = $this->decorated?->provide($operation, $uriVariables, $context) ?? ($context['request'] ?? null)?->attributes->get('data');
  6. if ($body instanceof Response || !$body) {
  7. return $body;
  8. }
  1. default:
  2. $isGranted = $operation->getSecurity();
  3. $message = $operation->getSecurityMessage();
  4. }
  5. $body = $this->decorated->provide($operation, $uriVariables, $context);
  6. if (null === $isGranted) {
  7. return $body;
  8. }
  9. // On a GraphQl QueryCollection we want to perform security stage only on the top-level query
  1. if (0 !== \count($constraintViolationList)) {
  2. throw new ValidationException($constraintViolationList);
  3. }
  4. return $this->decorated->provide($operation, $uriVariables, $context);
  5. }
  6. // There's a `property` inside Parameter but it's used for hydra:search only as here we want the parameter name instead
  7. private function getProperty(Parameter $parameter, ConstraintViolationInterface $violation): string
  8. {
  1. $request?->attributes->set('_api_operation', $operation);
  2. $context['operation'] = $operation;
  3. $this->stopwatch?->stop('api_platform.provider.parameter');
  4. return $this->decorated?->provide($operation, $uriVariables, $context);
  5. }
  6. /**
  7. * TODO: uriVariables could be a Parameters instance, it'd make things easier.
  8. *
  1. $this->addRequestFormats($request, $formats);
  2. $request->attributes->set('input_format', $this->getInputFormat($operation, $request));
  3. $request->setRequestFormat($this->getRequestFormat($request, $formats, !$isErrorOperation));
  4. $this->stopwatch?->stop('api_platform.provider.content_negotiation');
  5. return $this->decorated?->provide($operation, $uriVariables, $context);
  6. }
  7. /**
  8. * Adds the supported formats to the request.
  9. *
  1. || ('PUT' === $method && !($operation->getExtraProperties()['standard_put'] ?? true));
  2. $operation = $operation->withDenormalizationContext($denormalizationContext + [SerializerContextBuilderInterface::ASSIGN_OBJECT_TO_POPULATE => $assignObjectToPopulate]);
  3. }
  4. $body = $this->provider->provide($operation, $uriVariables, $context);
  5. // The provider can change the Operation, extract it again from the Request attributes
  6. if ($request->attributes->get('_api_operation') !== $operation) {
  7. $operation = $this->initializeOperation($request);
  1. $this->dispatcher->dispatch($event, KernelEvents::CONTROLLER_ARGUMENTS);
  2. $controller = $event->getController();
  3. $arguments = $event->getArguments();
  4. // call controller
  5. $response = $controller(...$arguments);
  6. // view
  7. if (!$response instanceof Response) {
  8. $event = new ViewEvent($this, $request, $type, $response, $event);
  9. $this->dispatcher->dispatch($event, KernelEvents::VIEW);
  1. $request->headers->set('X-Php-Ob-Level', (string) ob_get_level());
  2. $this->requestStack->push($request);
  3. $response = null;
  4. try {
  5. return $response = $this->handleRaw($request, $type);
  6. } catch (\Throwable $e) {
  7. if ($e instanceof \Error && !$this->handleAllThrowables) {
  8. throw $e;
  9. }
  1. if (!$this->handlingHttpCache) {
  2. $this->resetServices = true;
  3. }
  4. try {
  5. return $this->getHttpKernel()->handle($request, $type, $catch);
  6. } finally {
  7. --$this->requestStackSize;
  8. }
  9. }
  1. ) {
  2. }
  3. public function run(): int
  4. {
  5. $response = $this->kernel->handle($this->request);
  6. if (Kernel::VERSION_ID >= 60400) {
  7. $response->send(false);
  8. if (\function_exists('fastcgi_finish_request') && !$this->debug) {
in vendor/autoload_runtime.php -> run (line 32)
  1. $app = $app(...$args);
  2. exit(
  3. $runtime
  4. ->getRunner($app)
  5. ->run()
  6. );
require_once('/usr/src/app/vendor/autoload_runtime.php') in public/index.php (line 5)
  1. <?php
  2. use App\Kernel;
  3. require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
  4. return function (array $context) {
  5. return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
  6. };

Logs

Level Channel Message
INFO 18:22:21 request Matched route "_profiler".
{
    "route": "_profiler",
    "route_parameters": {
        "_route": "_profiler",
        "_controller": "web_profiler.controller.profiler::panelAction",
        "token": "3fb09c"
    },
    "request_uri": "http://api.dev.newretail.avp.tech/_profiler/3fb09c?panel=exception&type=request",
    "method": "GET"
}
DEBUG 18:22:21 event Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::configure".
{
    "event": "kernel.request",
    "listener": "Symfony\\Component\\HttpKernel\\EventListener\\DebugHandlersListener::configure"
}
DEBUG 18:22:21 event Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ValidateRequestListener::onKernelRequest".
{
    "event": "kernel.request",
    "listener": "Symfony\\Component\\HttpKernel\\EventListener\\ValidateRequestListener::onKernelRequest"
}
DEBUG 18:22:21 event Notified event "kernel.request" to listener "Nelmio\CorsBundle\EventListener\CorsListener::onKernelRequest".
{
    "event": "kernel.request",
    "listener": "Nelmio\\CorsBundle\\EventListener\\CorsListener::onKernelRequest"
}
DEBUG 18:22:21 event Notified event "kernel.request" to listener "Symfony\Bridge\Doctrine\Middleware\IdleConnection\Listener::onKernelRequest".
{
    "event": "kernel.request",
    "listener": "Symfony\\Bridge\\Doctrine\\Middleware\\IdleConnection\\Listener::onKernelRequest"
}
DEBUG 18:22:21 event Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\SessionListener::onKernelRequest".
{
    "event": "kernel.request",
    "listener": "Symfony\\Component\\HttpKernel\\EventListener\\SessionListener::onKernelRequest"
}
DEBUG 18:22:21 event Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::setDefaultLocale".
{
    "event": "kernel.request",
    "listener": "Symfony\\Component\\HttpKernel\\EventListener\\LocaleListener::setDefaultLocale"
}
DEBUG 18:22:21 event Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest".
{
    "event": "kernel.request",
    "listener": "Symfony\\Component\\HttpKernel\\EventListener\\RouterListener::onKernelRequest"
}
DEBUG 18:22:21 event Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelRequest".
{
    "event": "kernel.request",
    "listener": "Symfony\\Component\\HttpKernel\\EventListener\\LocaleListener::onKernelRequest"
}
DEBUG 18:22:21 event Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleAwareListener::onKernelRequest".
{
    "event": "kernel.request",
    "listener": "Symfony\\Component\\HttpKernel\\EventListener\\LocaleAwareListener::onKernelRequest"
}
DEBUG 18:22:21 event Notified event "kernel.request" to listener "Symfony\Bundle\SecurityBundle\Debug\TraceableFirewallListener::configureLogoutUrlGenerator".
{
    "event": "kernel.request",
    "listener": "Symfony\\Bundle\\SecurityBundle\\Debug\\TraceableFirewallListener::configureLogoutUrlGenerator"
}
DEBUG 18:22:21 event Notified event "kernel.request" to listener "Symfony\Bundle\SecurityBundle\Debug\TraceableFirewallListener::onKernelRequest".
{
    "event": "kernel.request",
    "listener": "Symfony\\Bundle\\SecurityBundle\\Debug\\TraceableFirewallListener::onKernelRequest"
}
DEBUG 18:22:21 event Notified event "kernel.controller" to listener "Symfony\Bundle\FrameworkBundle\DataCollector\RouterDataCollector::onKernelController".
{
    "event": "kernel.controller",
    "listener": "Symfony\\Bundle\\FrameworkBundle\\DataCollector\\RouterDataCollector::onKernelController"
}
DEBUG 18:22:21 event Notified event "kernel.controller" to listener "App\EventListener\DeviceActivityListener::onController".
{
    "event": "kernel.controller",
    "listener": "App\\EventListener\\DeviceActivityListener::onController"
}
DEBUG 18:22:21 event Notified event "kernel.controller" to listener "App\EventListener\UserActivityListener::onController".
{
    "event": "kernel.controller",
    "listener": "App\\EventListener\\UserActivityListener::onController"
}
DEBUG 18:22:21 event Notified event "kernel.controller" to listener "Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::onKernelController".
{
    "event": "kernel.controller",
    "listener": "Symfony\\Component\\HttpKernel\\DataCollector\\RequestDataCollector::onKernelController"
}
DEBUG 18:22:21 event Notified event "kernel.controller_arguments" to listener "Symfony\Component\HttpKernel\EventListener\IsSignatureValidAttributeListener::onKernelControllerArguments".
{
    "event": "kernel.controller_arguments",
    "listener": "Symfony\\Component\\HttpKernel\\EventListener\\IsSignatureValidAttributeListener::onKernelControllerArguments"
}
DEBUG 18:22:21 event Notified event "kernel.controller_arguments" to listener "Symfony\Component\Security\Http\EventListener\IsCsrfTokenValidAttributeListener::onKernelControllerArguments".
{
    "event": "kernel.controller_arguments",
    "listener": "Symfony\\Component\\Security\\Http\\EventListener\\IsCsrfTokenValidAttributeListener::onKernelControllerArguments"
}
DEBUG 18:22:21 event Notified event "kernel.controller_arguments" to listener "Symfony\Component\Security\Http\EventListener\IsGrantedAttributeListener::onKernelControllerArguments".
{
    "event": "kernel.controller_arguments",
    "listener": "Symfony\\Component\\Security\\Http\\EventListener\\IsGrantedAttributeListener::onKernelControllerArguments"
}
DEBUG 18:22:21 event Notified event "kernel.controller_arguments" to listener "Symfony\Component\HttpKernel\EventListener\CacheAttributeListener::onKernelControllerArguments".
{
    "event": "kernel.controller_arguments",
    "listener": "Symfony\\Component\\HttpKernel\\EventListener\\CacheAttributeListener::onKernelControllerArguments"
}
DEBUG 18:22:21 event Notified event "kernel.controller_arguments" to listener "ContainerNxKBOxo\RequestPayloadValueResolverGhost01ca9cc::onKernelControllerArguments".
{
    "event": "kernel.controller_arguments",
    "listener": "ContainerNxKBOxo\\RequestPayloadValueResolverGhost01ca9cc::onKernelControllerArguments"
}
DEBUG 18:22:21 event Notified event "kernel.controller_arguments" to listener "Symfony\Component\HttpKernel\EventListener\ErrorListener::onControllerArguments".
{
    "event": "kernel.controller_arguments",
    "listener": "Symfony\\Component\\HttpKernel\\EventListener\\ErrorListener::onControllerArguments"
}

Stack Trace

TypeError
TypeError:
App\Security\Voter\BrandSubresourceVoter::voteOnIteratorAggregate(): Argument #1 ($user) must be of type App\Entity\User|App\Entity\Device, null given, called in /usr/src/app/src/Security/Voter/BrandSubresourceVoter.php on line 52

  at src/Security/Voter/BrandSubresourceVoter.php:96
  at App\Security\Voter\BrandSubresourceVoter->voteOnIteratorAggregate()
     (src/Security/Voter/BrandSubresourceVoter.php:52)
  at App\Security\Voter\BrandSubresourceVoter->vote()
     (vendor/symfony/security-core/Authorization/Voter/TraceableVoter.php:35)
  at Symfony\Component\Security\Core\Authorization\Voter\TraceableVoter->vote()
     (vendor/symfony/security-core/Authorization/AccessDecisionManager.php:89)
  at Symfony\Component\Security\Core\Authorization\AccessDecisionManager->collectResults()
     (vendor/symfony/security-core/Authorization/Strategy/UnanimousStrategy.php:36)
  at Symfony\Component\Security\Core\Authorization\Strategy\UnanimousStrategy->decide()
     (vendor/symfony/security-core/Authorization/AccessDecisionManager.php:73)
  at Symfony\Component\Security\Core\Authorization\AccessDecisionManager->decide()
     (vendor/symfony/security-core/Authorization/TraceableAccessDecisionManager.php:57)
  at Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager->decide()
     (vendor/symfony/security-core/Authorization/AuthorizationChecker.php:54)
  at Symfony\Component\Security\Core\Authorization\AuthorizationChecker->isGranted()
     (vendor/api-platform/core/src/Symfony/Security/Core/Authorization/ExpressionLanguageProvider.php:29)
  at ApiPlatform\Symfony\Security\Core\Authorization\ExpressionLanguageProvider::ApiPlatform\Symfony\Security\Core\Authorization\{closure}()
     (vendor/symfony/expression-language/Node/FunctionNode.php:50)
  at Symfony\Component\ExpressionLanguage\Node\FunctionNode->evaluate()
     (vendor/symfony/expression-language/Node/BinaryNode.php:105)
  at Symfony\Component\ExpressionLanguage\Node\BinaryNode->evaluate()
     (vendor/symfony/expression-language/ExpressionLanguage.php:59)
  at Symfony\Component\ExpressionLanguage\ExpressionLanguage->evaluate()
     (vendor/api-platform/core/src/Symfony/Security/ResourceAccessChecker.php:57)
  at ApiPlatform\Symfony\Security\ResourceAccessChecker->isGranted()
     (vendor/api-platform/core/src/Symfony/Security/State/AccessCheckerProvider.php:87)
  at ApiPlatform\Symfony\Security\State\AccessCheckerProvider->provide()
     (vendor/api-platform/core/src/State/Provider/SecurityParameterProvider.php:50)
  at ApiPlatform\State\Provider\SecurityParameterProvider->provide()
     (vendor/api-platform/core/src/State/Provider/DeserializeProvider.php:60)
  at ApiPlatform\State\Provider\DeserializeProvider->provide()
     (vendor/api-platform/core/src/Symfony/Security/State/AccessCheckerProvider.php:62)
  at ApiPlatform\Symfony\Security\State\AccessCheckerProvider->provide()
     (vendor/api-platform/core/src/Symfony/Validator/State/ValidateProvider.php:32)
  at ApiPlatform\Symfony\Validator\State\ValidateProvider->provide()
     (vendor/api-platform/core/src/Symfony/Security/State/AccessCheckerProvider.php:62)
  at ApiPlatform\Symfony\Security\State\AccessCheckerProvider->provide()
     (vendor/api-platform/core/src/Symfony/Validator/State/ParameterValidatorProvider.php:101)
  at ApiPlatform\Symfony\Validator\State\ParameterValidatorProvider->provide()
     (vendor/api-platform/core/src/State/Provider/ParameterProvider.php:102)
  at ApiPlatform\State\Provider\ParameterProvider->provide()
     (vendor/api-platform/core/src/State/Provider/ContentNegotiationProvider.php:56)
  at ApiPlatform\State\Provider\ContentNegotiationProvider->provide()
     (vendor/api-platform/core/src/Symfony/Controller/MainController.php:94)
  at ApiPlatform\Symfony\Controller\MainController->__invoke()
     (vendor/symfony/http-kernel/HttpKernel.php:183)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw()
     (vendor/symfony/http-kernel/HttpKernel.php:76)
  at Symfony\Component\HttpKernel\HttpKernel->handle()
     (vendor/symfony/http-kernel/Kernel.php:193)
  at Symfony\Component\HttpKernel\Kernel->handle()
     (vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:35)
  at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run()
     (vendor/autoload_runtime.php:32)
  at require_once('/usr/src/app/vendor/autoload_runtime.php')
     (public/index.php:5)