Meilisearch-laravel-scout: Bug with symfony/http-client

Created on 26 Sep 2020  ·  8Comments  ·  Source: meilisearch/meilisearch-laravel-scout

As you know symfony/http-client is required in plenty of packages but it was giving me the error so I removed them to test meilisearch than installed http/guzzle6-adapter and everything seems to work ok than I installed the packages that I have removed they installed symfony/http-client and as I guess laravel gives priority to it and I am getting this error again. I have also tried to install symfony/http-client nyholm/psr7 as you suggested in readme but still getting the error. What do you think what will be solution for it.

Have also tried to update guzzle to 7.0 but still not working as expected, I think there is something with php version what will be your solution?

Using:
Laravel: 6.18.40
PHP: 7.4.5

Any request to mailisearch using symfony/http-client returns the error:

   ErrorException  : Trying to access array offset on value of type null

  at /var/www/vendor/symfony/http-client/HttpClientTrait.php:417
    413|                     $url['query'] = '?'.self::mergeQueryString(substr($url['query'] ?? '', 1), $queryDefaults, false);
    414|                 }
    415|             }
    416| 
  > 417|             $url['scheme'] = $base['scheme'];
    418|         }
    419| 
    420|         if ('' === ($url['path'] ?? '')) {
    421|             $url['path'] = '/';

  Exception trace:

  1   Illuminate\Foundation\Bootstrap\HandleExceptions::handleError()
      /var/www/vendor/symfony/http-client/HttpClientTrait.php:417

  2   Symfony\Component\HttpClient\CurlHttpClient::resolveUrl()
      /var/www/vendor/symfony/http-client/HttpClientTrait.php:141

Most helpful comment

@shokme So I have found out my problem was with docker configuration and env variable. I had MEILISEARCH_HOST=meilisearch in my env that was working perfectly with guzzle 6,7 and php-http/curl-client, that was driving me crazy when only symfony/http-client was crashing. So I checked vendor/symfony/http-client/HttpClientTrait.php source and found our that their resolveUrl() was crashing without "proper" url name so I changed my MEILISEARCH_HOST=meilisearch to MEILISEARCH_HOST=http://meilisearch:7070 and that's it now it works. Thanks again I am staying with meilisearch and closing issue.

All 8 comments

I have not problem using symfony/http-client with nyholm/psr7
laravel 6.18.40 and php 7.4.3
be sure to use "meilisearch/meilisearch-laravel-scout": "^0.12.0" in your composer.json

@shokme Thanks for feedback but I am using "meilisearch/meilisearch-laravel-scout": "^0.12.0"
"symfony/http-client": "^5.1"
and
"nyholm/psr7": "^1.3"
You have the same versions?

yes, everything is the same.

But I do a very simple call

$movies = Movie::search('Ready Player One')->raw();

But as you said:

Any request to mailisearch using symfony/http-client returns the error:

So I don't think the error come from your call.

@shokme yes you are right that's not about the call, I have tried several combinations in my project so guzzle 6 with adapter works well, after clearing some packages guzzle 7 started working fine with whole config and mailisearch, but symfony/http-client still stays problem for me. If I will have any solution will write it down. Thanks for your time.

Ok, I'm sorry to not be able to help you further.

perhaps doing some dd($url) around symfony/http-client/HttpClientTrait.php:417 can show you some hints.

@shokme Still thanks a lot for time and help, the same configuration that we both have gives me hopes that I have something mistaken so I will continue investigation thanks again.

@shokme So I have found out my problem was with docker configuration and env variable. I had MEILISEARCH_HOST=meilisearch in my env that was working perfectly with guzzle 6,7 and php-http/curl-client, that was driving me crazy when only symfony/http-client was crashing. So I checked vendor/symfony/http-client/HttpClientTrait.php source and found our that their resolveUrl() was crashing without "proper" url name so I changed my MEILISEARCH_HOST=meilisearch to MEILISEARCH_HOST=http://meilisearch:7070 and that's it now it works. Thanks again I am staying with meilisearch and closing issue.

Thanks for your investigation @JexPY! Be sure it will be helpful for users coming after you 👍

Was this page helpful?
0 / 5 - 0 ratings

Related issues

curquiza picture curquiza  ·  17Comments

marky291 picture marky291  ·  6Comments

Cannonb4ll picture Cannonb4ll  ·  6Comments

milosevicn picture milosevicn  ·  5Comments

curquiza picture curquiza  ·  4Comments