ControllerDoesNotReturnResponseException: The controller must return a "Symfony\Component\HttpFoundation\Response" object but it returned null

Created on 15 January 2025, 7 days ago

Problem/Motivation

In the callback controller, if $content['Payload']['NewStatus'] does not equal TranslationReady, the following exception is thrown:

Symfony\Component\HttpKernel\Exception\ControllerDoesNotReturnResponseException: The controller must return a "Symfony\Component\HttpFoundation\Response" object but it returned null. Did you forget to add a return statement somewhere in your controller?
  File "/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php", line 98
    });
  File "/core/lib/Drupal/Core/StackMiddleware/Session.php", line 53, in Drupal\Core\StackMiddleware\Session::handle
    $result = $this->httpKernel->handle($request, $type, $catch);
  File "/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php", line 48, in Drupal\Core\StackMiddleware\KernelPreHandle::handle
    return $this->httpKernel->handle($request, $type, $catch);
  File "/core/lib/Drupal/Core/StackMiddleware/ContentLength.php", line 28, in Drupal\Core\StackMiddleware\ContentLength::handle
    $response = $this->httpKernel->handle($request, $type, $catch);
  File "/core/modules/page_cache/src/StackMiddleware/PageCache.php", line 106, in Drupal\page_cache\StackMiddleware\PageCache::pass
    return $this->httpKernel->handle($request, $type, $catch);
...
(10 additional frame(s) were not displayed)

Symfony\Component\HttpKernel\Exception\ControllerDoesNotReturnResponseException: The controller must return a "Symfony\Component\HttpFoundation\Response" object but it returned null. Did you forget to add a return statement somewhere in your controller? in () (line 98 of /[...]/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php).

Proposed resolution

Always return a response in the controller.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇧🇪Belgium dieterholvoet Brussels

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024