Meilisearch-laravel-scout: Wrong parameters for MeiliSearch\Exceptions\HTTPRequestException

Created on 10 Aug 2020  ·  14Comments  ·  Source: meilisearch/meilisearch-laravel-scout

Started getting this exception after upgrading to the latest version yesterday of this package.

Stacktrace:

[2020-08-10 15:22:11] production.ERROR: Wrong parameters for MeiliSearch\Exceptions\HTTPRequestException([string $message [, long $code [, Throwable $previous = NULL]]]) {"exception":"[object] (Error(code: 0): Wrong parameters for MeiliSearch\\Exceptions\\HTTPRequestException([string $message [, long $code [, Throwable $previous = NULL]]]) at /home/redacted/vendor/meilisearch/meilisearch-php/src/Exceptions/HTTPRequestException.php:20)
[stacktrace]
#0 /home/redacted/vendor/meilisearch/meilisearch-php/src/Exceptions/HTTPRequestException.php(20): Exception->__construct()
#1 /home/redacted/vendor/meilisearch/meilisearch-php/src/Http/Client.php(182): MeiliSearch\\Exceptions\\HTTPRequestException->__construct()
#2 /home/redacted/vendor/meilisearch/meilisearch-php/src/Http/Client.php(165): MeiliSearch\\Http\\Client->parseResponse()
#3 /home/redacted/vendor/meilisearch/meilisearch-php/src/Http/Client.php(101): MeiliSearch\\Http\\Client->execute()
#4 /home/redacted/vendor/meilisearch/meilisearch-php/src/Endpoints/Delegates/HandlesDocuments.php(29): MeiliSearch\\Http\\Client->post()
#5 /home/redacted/vendor/meilisearch/meilisearch-laravel-scout/src/Engines/MeilisearchEngine.php(59): MeiliSearch\\Endpoints\\Indexes->addDocuments()
#6 /home/redacted/vendor/laravel/scout/src/Jobs/MakeSearchable.php(42): Meilisearch\\Scout\\Engines\\MeilisearchEngine->update()
#7 [internal function]: Laravel\\Scout\\Jobs\\MakeSearchable->handle()
Laravel integration

All 14 comments

Same issue here, after updating this package i needed to update this code example taken from the Readme like below =>

Book::search('prince', function (Index $meilisearch, $query, $options) {
    $options['filters'] = 'author="Antoine de Saint-Exupéry"';

    return $meilisearch->search($query, $options);
})->take(3)->get();

To

Book::search('prince', function (Indexes $meilisearch, $query, $options) {
    $options['filters'] = 'author="Antoine de Saint-Exupéry"';

    return $meilisearch->search($query, $options);
})->take(3)->get();

See the $meilisearch parameter, was typed hint to Meilisearch\Index before, but now we need to type hint it to MeiliSearch\Endpoints\Indexes.

And then i have this issue :

[2020-08-11 15:56:50] local.ERROR: Wrong parameters for MeiliSearch\Exceptions\HTTPRequestException([string $message [, long $code [, Throwable $previous = NULL]]]) {"userId":2,"exception":"[object] (Error(code: 0): Wrong parameters for MeiliSearch\\Exceptions\\HTTPRequestException([string $message [, long $code [, Throwable $previous = NULL]]]) at /var/www/html/vendor/meilisearch/meilisearch-php/src/Exceptions/HTTPRequestException.php:20)
[stacktrace]
#0 /var/www/html/vendor/meilisearch/meilisearch-php/src/Exceptions/HTTPRequestException.php(20): Exception->__construct(NULL, 405, NULL)
#1 /var/www/html/vendor/meilisearch/meilisearch-php/src/Http/Client.php(182): MeiliSearch\\Exceptions\\HTTPRequestException->__construct(405, NULL)
#2 /var/www/html/vendor/meilisearch/meilisearch-php/src/Http/Client.php(165): MeiliSearch\\Http\\Client->parseResponse(Object(GuzzleHttp\\Psr7\\Response))
#3 /var/www/html/vendor/meilisearch/meilisearch-php/src/Http/Client.php(101): MeiliSearch\\Http\\Client->execute(Object(GuzzleHttp\\Psr7\\Request))
#4 /var/www/html/vendor/meilisearch/meilisearch-php/src/Endpoints/Indexes.php(127): MeiliSearch\\Http\\Client->post('/indexes/compan...', Array)
#5 /var/www/html/app/Models/Company.php(394): MeiliSearch\\Endpoints\\Indexes->search('oj', Array)
#6 [internal function]: App\\Models\\Company::App\\Models\\{closure}(Object(MeiliSearch\\Endpoints\\Indexes), 'oj', Array)
#7 /var/www/html/vendor/meilisearch/meilisearch-laravel-scout/src/Engines/MeilisearchEngine.php(128): call_user_func(Object(Closure), Object(MeiliSearch\\Endpoints\\Indexes), 'oj', Array)
#8 /var/www/html/vendor/meilisearch/meilisearch-laravel-scout/src/Engines/MeilisearchEngine.php(92): Meilisearch\\Scout\\Engines\\MeilisearchEngine->performSearch(Object(Laravel\\Scout\\Builder), Array)
#9 /var/www/html/vendor/laravel/scout/src/Builder.php(220): Meilisearch\\Scout\\Engines\\MeilisearchEngine->search(Object(Laravel\\Scout\\Builder))
#10 /var/www/html/app/Models/Company.php(396): Laravel\\Scout\\Builder->raw()
#11 /var/www/html/app/Http/Livewire/Admin/ShowCompanies.php(171): App\\Models\\Company::searchBy('oj', Array)
#12 /var/www/html/vendor/livewire/livewire/src/Component.php(99): App\\Http\\Livewire\\Admin\\ShowCompanies->render()
#13 /var/www/html/vendor/livewire/livewire/src/Connection/ConnectionHandler.php(29): Livewire\\Component->output(NULL)
#14 /var/www/html/vendor/livewire/livewire/src/Controllers/HttpConnectionHandler.php(13): Livewire\\Connection\\ConnectionHandler->handle(Array)
#15 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(48): Livewire\\Controllers\\HttpConnectionHandler->__invoke('admin.show-comp...')
#16 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(239): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(Livewire\\Controllers\\HttpConnectionHandler), '__invoke')
#17 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(196): Illuminate\\Routing\\Route->runController()
#18 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(685): Illuminate\\Routing\\Route->run()
#19 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#20 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#21 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#22 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(77): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#23 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#24 /var/www/html/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#25 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#26 /var/www/html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#27 /var/www/html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(62): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest(Object(Illuminate\\Http\\Request), Object(Illuminate\\Session\\Store), Object(Closure))
#28 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Session\\Middleware\\StartSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#29 /var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#30 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#31 /var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#32 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#33 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#34 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(687): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#35 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(662): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#36 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(628): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#37 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(617): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#38 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(165): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#39 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#40 /var/www/html/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(65): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#41 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Barryvdh\\Debugbar\\Middleware\\InjectDebugbar->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#42 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#43 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#44 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(63): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#45 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#46 /var/www/html/vendor/fruitcake/laravel-cors/src/HandleCors.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#47 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fruitcake\\Cors\\HandleCors->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#48 /var/www/html/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#49 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#50 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#51 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(140): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#52 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(109): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#53 /var/www/html/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#54 {main}
"} 

Hello guys!

So sorry, the previous release should have been a new minor (v0.11.0 instead of v0.10.7). We did not realize it was breaking! Sorry about that!

@YannickYayo, thanks for the fix! This PR #38 takes into account what you said! Is it enough for you or did I miss something? 🙂

@dmyers, does the fix of @YannickYayo solve your problem?

@dmyers and @YannickYayo (and @shokme). Another question: do you think we should remove the v0.10.7 from Packagist and from GitHub and create a new v0.11.0? Or just creating a new v0.11.0 is enough?

Oh i forgot to to mention it, but my little fix doesn't solve the issue with Wrong parameters for MeiliSearch\Exceptions\HTTPRequestException... :(
I'll try to debug it and provide feedback.

In my opinion, creating a new v0.11.0 is enough, may be you can write a warning about the v0.10.7.

Yeah I had already made the same change as @YannickYayo did with the typehint for the index and had this exception occur afterwards.

Sorry accidentally closed by misclick mistake.

Agree w/ @Yannick on the versioning, but I don't really know much about semver or best practices on that stuff to be honest most of my packages are used just by me. 😄

Btw this won't simply be fixed with #38 because this exception is caused by a recent change from the upstream MeiliSearch PHP dependency that added compatibility with v0.13.

https://github.com/meilisearch/meilisearch-laravel-scout/releases/tag/v0.10.7

Update :

I was using the 0.12 version of the Meilisearch engine, after upgrading it on docker to the 0.13 and re-indexing my documents, it fixes the issue for me !

Ok sorry guys, I went to fast, I understand my PR does not fix anything except a small part of the README 😅

So now @YannickYayo, I understand your problem is fixed, right? I've updated the README in #38 according to what you said: meilisearch-laravel-scout v0.10.7 is not compatible with MeiliSearch v0.12.0 and before

@dmyers, I understand your issue is still there despite:

  • the change of Index into Indexes
  • the update of your MeiliSearch instance (v0.13.0)

Right?

@curquiza Yep, using Meilisearch v0.13.0 fixed my issue :+1:

I have been using the v0.13.0 version since before I opened this issue.

I'm still getting this error as of today, but it seems to be caused by the PHP SDK if my search server instance is down which is happening at random times and only solution is for me to restart it, but it still is not ideal that Meilisearch official PHP SDK doesn't handle proper exception status code for that case.

I believe the root cause to be poor use of the Exception class extension in HTTPRequestException class which improperly swaps the argument order of the Exception class in PHP stdlib.

Here you can see the order of the args for Exception:
https://www.php.net/manual/en/exception.construct.php

Now look at the order of args for HTTPRequestException:
https://github.com/meilisearch/meilisearch-php/blob/master/src/Exceptions/HTTPRequestException.php#L15

So now back to Laravel, somehow my MeiliSearch server freezes or something and this error floods my failed_jobs table and once I restart it is resolved, but this issue began after upgrading this package. I have about 80,000 records in this table from this since I upgraded.

Screen Shot 2020-08-17 at 4 18 34 PM

Oh sorry @dmyers, this issue shouldn't have been closed, my bad, it has been done automatically by GitHub because I linked the issue!

Can you provide the part of the code that failed? Because it's currently complicated for us to guess what happened without details. I did not succeed to get your Error.
In any case, MeiliSearch should not freeze no matter what you do. A context would be really helpful to report it and to fix the Error 🙂

@dmyers an update has been pushed, this should solved the "Wrong parameters".

You must update the package to the version ^0.12, that will also require you to add an httpclient and factory you can see the detail in the installation instruction from the readme.

Thank you so much for the update @shokme. I was still seeing these exceptions in my failed jobs table in my Laravel app, but was finding it difficult to get a reproducible test case to share and so I'm glad you were able to solve it.

I'll test out the new version shortly.

Hello @dmyers, is this still an issue, can I close it? :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

husonghua picture husonghua  ·  5Comments

curquiza picture curquiza  ·  17Comments

ctf0 picture ctf0  ·  7Comments

marky291 picture marky291  ·  6Comments

Kladislav picture Kladislav  ·  8Comments