esmero / ami

Archipelago Multi Importer. A module of mass ingest made for the masses
GNU Affero General Public License v3.0
2 stars 4 forks source link

When running AMI LoD twig extension via Hydroponics we have no request domain/failure #199

Open DiegoPino opened 5 months ago

DiegoPino commented 5 months ago

What?

New to me. But might have happened before too. Might also be a Drupal 10 change because I remember ingesting with AMI LOD Twig extensions via background hydroponics.

But the error exists now

GuzzleHttp\Exception\RequestException thrown in /var/www/html/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:211 while querying for @entity_type entity ids matching "Author". Message: cURL error 3: URL rejected: Port number was not a decimal number between 0 and 65535 (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for ://:8001/webform_strawberry/auth_autocomplete/loc/relators?_format=json&q=Author

Which happens at

\Drupal\ami\TwigExtension::amiLodReconcile

when we request the current domain to initialize the controller manually

Here:

 try {
      $domain = \Drupal::service('request_stack')->getCurrentRequest()->getSchemeAndHttpHost();
     // $domain ends only having the 8001 without the scheme and host. (because it is detached.)
      $lod_route_argument_list = explode(";", $vocab);
      $lod = \Drupal::service('ami.lod')->invokeLoDRoute($domain,
        $label, $lod_route_argument_list[0],
        $lod_route_argument_list[1], $lod_route_argument_list[2], $len ?? 'en', 1);
    }

The solution here is either to use the internal esmero-web when running on background (which brings an issue with cookies/sessions) or do something totally different

    $controller = $this->classResolver->getInstanceFromDefinition('\Drupal\my_module\Controller\MyController');
    return $controller->build();

Where we initialize the controller not by invoking the route, but via a class resolver/instance from the code directly

@alliomeria this is an issue for our huge background ingests so will have to tackle tomorrow early AM (will try)