EmicoEcommerce / Magento2Tweakwise

Magento 2 module for Tweakwise integration
Other
4 stars 16 forks source link

When searching for empty query, a 400 bad request occurs #167

Open evs-xsarus opened 3 months ago

evs-xsarus commented 3 months ago

Issue Brief

What is the purpose of this issue? Explain the background context.

Environment

Steps to reproduce

Start searching for suggestions, if this happens too soon, there is no search term. The request will be :

https://gateway.tweakwisenavigator.com/suggestions/090bb431?tn_q=&tn_cid=100032

Actual result

This will then return a GuzzleHttp\Exception\ClientException: Client error: 400 Bad request

Stack trace:

#0 /mysite/vendor/guzzlehttp/guzzle/src/Middleware.php(72): GuzzleHttp\Exception\RequestException::create()
#1 /mysite/vendor/guzzlehttp/promises/src/Promise.php(209): GuzzleHttp\Middleware::GuzzleHttp\{closure}()
#2 /mysite/vendor/guzzlehttp/promises/src/Promise.php(158): GuzzleHttp\Promise\Promise::callHandler()
#3 /mysite/vendor/guzzlehttp/promises/src/TaskQueue.php(52): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
#4 /mysite/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(163): GuzzleHttp\Promise\TaskQueue->run()
#5 /mysite/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(189): GuzzleHttp\Handler\CurlMultiHandler->tick()
#6 /mysite/vendor/guzzlehttp/promises/src/Promise.php(251): GuzzleHttp\Handler\CurlMultiHandler->execute()
#7 /mysite/vendor/guzzlehttp/promises/src/Promise.php(227): GuzzleHttp\Promise\Promise->invokeWaitFn()
#8 /mysite/vendor/guzzlehttp/promises/src/Promise.php(272): GuzzleHttp\Promise\Promise->waitIfPending()
#9 /mysite/vendor/guzzlehttp/promises/src/Promise.php(229): GuzzleHttp\Promise\Promise->invokeWaitList()
#10 /mysite/vendor/guzzlehttp/promises/src/Promise.php(69): GuzzleHttp\Promise\Promise->waitIfPending()
#11 /mysite/vendor/guzzlehttp/promises/src/Utils.php(121): GuzzleHttp\Promise\Promise->wait()
#12 /mysite/vendor/tweakwise/magento2-tweakwise/Model/Autocomplete/DataProvider/SuggestionDataProvider.php(149): GuzzleHttp\Promise\Utils::unwrap()
#13 /mysite/vendor/tweakwise/magento2-tweakwise/Model/Autocomplete/DataProvider.php(40): Tweakwise\Magento2Tweakwise\Model\Autocomplete\DataProvider\SuggestionDataProvider->getItems()
#14 /mysite/vendor/magento/module-search/Model/Autocomplete.php(35): Tweakwise\Magento2Tweakwise\Model\Autocomplete\DataProvider->getItems()
#15 /mysite/vendor/magento/module-search/Controller/Ajax/Suggest.php(45): Magento\Search\Model\Autocomplete->getItems()
#16 /mysite/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Search\Controller\Ajax\Suggest->execute()
#17 /mysite/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Search\Controller\Ajax\Suggest\Interceptor->callParent()
#18 /mysite/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Search\Controller\Ajax\Suggest\Interceptor->Magento\Framework\Interception\{closure}()
#19 /mysite/generated/code/Magento/Search/Controller/Ajax/Suggest/Interceptor.php(23): Magento\Search\Controller\Ajax\Suggest\Interceptor->_callPlugins()
#20 /mysite/vendor/magento/framework/App/Action/Action.php(111): Magento\Search\Controller\Ajax\Suggest\Interceptor->execute()
#21 /mysite/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Action\Action->dispatch()
#22 /mysite/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Search\Controller\Ajax\Suggest\Interceptor->callParent()
#23 /mysite/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Search\Controller\Ajax\Suggest\Interceptor->Magento\Framework\Interception\{closure}()
#24 /mysite/generated/code/Magento/Search/Controller/Ajax/Suggest/Interceptor.php(32): Magento\Search\Controller\Ajax\Suggest\Interceptor->callPlugins()
#25 /mysite/vendor/magento/framework/App/FrontController.php(245): Magento\Search\Controller\Ajax\Suggest\Interceptor->dispatch()
#26 /mysite/vendor/magento/framework/App/FrontController.php(212): Magento\Framework\App\FrontController->getActionResponse()
#27 /mysite/vendor/magento/framework/App/FrontController.php(146): Magento\Framework\App\FrontController->processRequest()
#28 /mysite/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch()
#29 /mysite/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->callParent()
#30 /mysite/vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(112): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
#31 /mysite/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch()
#32 /mysite/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(71): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
#33 /mysite/vendor/magento/framework/Interception/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch()
#34 /mysite/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
#35 /mysite/generated/code/Magento/Framework/App/FrontController/Interceptor.php(23): Magento\Framework\App\FrontController\Interceptor->_callPlugins()
#36 /mysite/vendor/magento/framework/App/Http.php(116): Magento\Framework\App\FrontController\Interceptor->dispatch()
#37 /mysite/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http->launch()
#38 /mysite/pub/index.php(147): Magento\Framework\App\Bootstrap->run()
#39 {main}

Expected result

The request will not happen and the calling function will return an empty result.

ah-net commented 2 months ago

@evs-xsarus Which theme are you using? Because both luma and hyva theme seem to prevent searching of empty strings, and only start searching if you've typed 3 characters. I can't reproduce the issue there.

So i think this may be an issue in the theme you are using.

evs-xsarus commented 2 months ago

This is a custom theme and it can thus occur there is no query. Is it possible to start a request to Tweakwise only if there is a value in tn_q ? Or prevent the Tweakwise part breaking on an empty tn_q ?

ah-net commented 2 months ago

@evs-xsarus I'll check. If it's easy to implement we will add an check on an empty q value

evs-xsarus commented 1 month ago

@ah-net did you manage to add the check on an empty q value?

ah-net commented 1 month ago

@evs-xsarus Not yet, this ticket is added to our backlog. But due to other priorities this hasn't been done yet. It is not known when we will look into this issue.

ah-net commented 1 day ago

@evs-xsarus Wat is the exact ajax url that causes this issue? Because I can't reproduce it. If I call the ajax url without an q value, it redirects and TW is never called. /search/ajax/suggest/?q=

evs-xsarus commented 1 day ago

Hi, You can reproduce it on:

https://www.dille-kamille.nl/eten-drinken/drinken/thee/

In the searchbar, enter a few spaces and then a character, e.g. d seems to triiger this. The call goes to Magento and then to Tweakwise

https://gateway.tweakwisenavigator.net/suggestions/090bb431?tn_q=&tn_cid=100012

Call to Magento: https://www.dille-kamille.nl/search/ajax/suggest/cid/43/?q=%20%20&_=1719498299076

ah-net commented 1 day ago

@evs-xsarus Thx. The spaces seem to trigger the error. I'll see if i can find an solution for this.