Issue Bug New

#111504PageContentErrorHandler returns HTTP 200 when error page cannot be resolved (InvalidRouteArgumentsException / SiteNotFoundException)

Mario Wilhelm 11/19/26, 08:25 updated 11/19/26, 08:25

Description

Category: Link Handling, Site Handling & Routing
TYPO3 Version: 13.4.x>
PHP Version: 8.3.x>

Description

If the page configured in errorContentSource cannot be resolved for the current request, the PageContentErrorHandler responds with HTTP status 200 instead of the configured error status code (e.g. 404).

Resolving the error page throws an InvalidRouteArgumentsException or a SiteNotFoundException. The handler does not fall back to a response with the expected status code, so the error is sent to the client as a regular, successful response.

Consequences:
  • CDNs / reverse proxies cache the error response as a valid page
  • Search engines index it (soft 404)
  • HTTP-based monitoring does not detect the error at all

Even if the cause is a misconfiguration, a handler configured for a specific error status must never answer with 200. Expected behaviour is a generic error response carrying the status code the handler was configured for (compare the reasoning in #103399).

Steps to reproduce

1. Site configuration:

errorHandling:
  - errorCode: 404
    errorHandler: Page
    errorContentSource: 't3://page?uid=<uid>'

2. Make the error page unresolvable for the request, e.g.: * <uid> lies outside the page tree of the site -&gt; SiteNotFoundException * <uid> is not available in the requested language -&gt; InvalidRouteArgumentsException<br>3. Request a non-existing URL: <code>curl -I <a href="https://example.org/<lang>/does-not-exist" target="_blank" rel="noreferrer">https://example.org/&lt;lang&gt;/does-not-exist</a></code></uid></uid>

Expected result

HTTP 404 (generic error content is acceptable), plus a log entry stating why the error page could not be resolved.

Actual result

HTTP 200, response body: <generic error output empty></generic>

Log / stack trace:

<stack trace from var/log>

Workaround

Custom error handler (errorHandler: PHP) that wraps PageContentErrorHandler, catches the exception, logs it and enforces the configured status code via $response->withStatus($statusCode).

Related

  • #103818 Streamline PageContentErrorHandler
  • #104828 config.contentObjectExceptionHandler sends 200 HTTP Status and regular cache headers
  • #103399 (fallback behaviour for unavailable error page content)

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

Fix this issue

Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". How to create a patch

Commit message
[BUGFIX] PageContentErrorHandler returns HTTP 200 when error page cannot be resolved (InvalidRouteArgumentsException / SiteNotFoundException) Resolves: #111504 Releases: main