Core URL Validation Fatals on 404 and other errors

Created on 18 March 2023, almost 2 years ago
Updated 19 March 2023, almost 2 years ago

Problem/Motivation

When a domain returns a 404, the ajax that feeds the error message and throbber fatals with a WSOD

GuzzleHttp\Exception\ConnectException: cURL error 6: Could not resolve host: drupal-10.lndo.sit (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://drupal-10.lndo.sit in GuzzleHttp\Handler\CurlFactory::createRejection() (line 210 of /app/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php).
GuzzleHttp\Handler\CurlFactory::finishError(Object, Object, Object) (Line: 110)
GuzzleHttp\Handler\CurlFactory::finish(Object, Object, Object) (Line: 47)
GuzzleHttp\Handler\CurlHandler->__invoke(Object, Array) (Line: 28)
GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler\{closure}(Object, Array) (Line: 48)
GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler\{closure}(Object, Array) (Line: 35)
GuzzleHttp\PrepareBodyMiddleware->__invoke(Object, Array) (Line: 31)
GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object, Array) (Line: 55)
GuzzleHttp\RedirectMiddleware->__invoke(Object, Array) (Line: 63)
GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object, Array) (Line: 75)
GuzzleHttp\HandlerStack->__invoke(Object, Array) (Line: 331)
GuzzleHttp\Client->transfer(Object, Array) (Line: 168)
GuzzleHttp\Client->requestAsync('HEAD', Object, Array) (Line: 187)
GuzzleHttp\Client->request('HEAD', 'http://drupal-10.lndo.sit', Array) (Line: 61)
GuzzleHttp\Client->head('http://drupal-10.lndo.sit', Array) (Line: 208)
Drupal\drd\Entity\Form\Core->validateUrl(Array, Object) (Line: 313)
Drupal\drd\Entity\Form\Core->validateForm(Array, Object)
call_user_func_array(Array, Array) (Line: 82)
Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object) (Line: 275)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object, 'drd_core_add_form') (Line: 118)
Drupal\Core\Form\FormValidator->validateForm('drd_core_add_form', Array, Object) (Line: 591)
Drupal\Core\Form\FormBuilder->processForm('drd_core_add_form', Array, Object) (Line: 323)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 163)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 74)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 686)
Drupal\Core\DrupalKernel->handle(Ob

Steps to reproduce

I was able to recreate it using Lando and turning the lando instance off in which case lando's proxy on my machine sends back a 404. Theoretically this can be recreated with any Apache setup where a domain sends back a 404 for the main index page.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

4.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States generalredneck

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

Comments & Activities

  • Issue created by @generalredneck
  • πŸ‡ΊπŸ‡ΈUnited States generalredneck

    Just noticed that the one I just posted when I was trying to recreate was a curl 6... but I've got a screenshot of a 404 causing it attached.

  • @generalredneck opened merge request.
  • Status changed to Needs review almost 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States generalredneck

    So I noticed that we weren't really handling the response codes for anything other than 301 and 302... That said, the others probably always just failed like this. I did add some verbiage giving the user what the error message is... Not sure if this is even wanted. Also did a tiny bit of code clean up while I was in there.

  • First commit to issue fork.
  • Status changed to RTBC almost 2 years ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    So I noticed that we weren't really handling the response codes for anything other than 301 and 302... That said, the others probably always just failed like this. I did add some verbiage giving the user what the error message is

    This is great, thanks a lot.

    Not sure if this is even wanted. Also did a tiny bit of code clean up while I was in there.

    Absolutely, much appreciated. I only reverted the insertion of unused $e variables, since those are not only not required but also create a warning from code style tests since PHP 8.1

  • Status changed to Fixed almost 2 years ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024