Draft: Handle 4xx exceptions

Created on 19 October 2023, 8 months ago
Updated 20 October 2023, 8 months ago

Problem/Motivation

This is a draft still until the scope is concluded.

After https://www.drupal.org/project/drupal/issues/2828706 πŸ› ExceptionLoggingSubscriber should not log HTTP 4XX errors using PHP logger channel Needs work , when a user requests a different format than what is supported using the _format query parameter, the response code remains 406, but there is no exception thrown, as the \Drupal\Core\EventSubscriber\RenderArrayNonHtmlSubscriber::onRespond throws a NotAcceptableHttpException exception and this is later handled in the \Drupal\Core\EventSubscriber\FinalExceptionSubscriber::on4xx. This is not happening for our case as we provide more formats (turtle, rdf+xml etc).
As stated in the docblock of \Drupal\serialization\EventSubscriber\DefaultExceptionSubscriber::getPriority

    // This will fire after the most common HTML handler, since HTML requests
    // are still more common than HTTP requests. But it has a lower priority
    // than \Drupal\Core\EventSubscriber\ExceptionJsonSubscriber::on4xx(), so
    // that this also handles the 'json' format.

So, core provides the \Drupal\Core\EventSubscriber\ExceptionJsonSubscriber for exceptions related to json format etc, which means that we should probably do that ourselves.

Proposed resolution

Create an exception subscriber to handle 406 cases when the pages are not related to SPARQL storage.

πŸ› Bug report
Status

Closed: works as designed

Version

2.0

Component

Code

Created by

πŸ‡¬πŸ‡·Greece idimopoulos

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

Comments & Activities

  • Issue created by @idimopoulos
  • πŸ‡¬πŸ‡·Greece idimopoulos

    This turned out to not be really something that is worth intervening here. Core logs an exception by default and should not be part of this module to force avoid that.
    Projects should either handle this explicitly or it should be handled in core. Closing.

  • Issue was unassigned.
  • Status changed to Closed: works as designed 8 months ago
Production build 0.69.0 2024