laravel/scout

delete-all-indexes command not working with meilisearch/meilisearch-php 1.3.0+

vintagesucks opened this issue · 3 comments

Scout Version

10.4.0

Scout Driver

Meilisearch

Laravel Version

10.26.2

PHP Version

8.2.11

Database Driver & Version

No response

SDK Version

1.4.0

Meilisearch CLI Version

1.1.1

Description

Hi! The scout:delete-all-indexes command does not work when using meilisearch-php 1.3.0 or above. Updating my local Meilisearch container from 1.1.1 to 1.4.0 makes no difference.


meilisearch/meilisearch-php:1.2.1:

❯ php artisan scout:delete-all-indexes
All indexes deleted successfully.

meilisearch/meilisearch-php:1.3.0 or meilisearch/meilisearch-php:1.4.0:

❯ php artisan scout:delete-all-indexes
The provided API key is invalid.

Am I doing something wrong or is this a problem with Scout?

Steps To Reproduce

In a fresh Laravel install:

composer require laravel/scout
composer require meilisearch/meilisearch-php http-interop/http-factory-guzzle
# .env
SCOUT_DRIVER=meilisearch
MEILISEARCH_HOST=http://127.0.0.1:7700
MEILISEARCH_KEY=
php artisan scout:delete-all-indexes 

@vintagesucks

sorry to hear that. In your case this was a breaking change with some changes made in meilisearch/meilisearch-php#514 where the check for an api key was previously null != $apikey and now there is a null !== $apikey

null != '' would return false in meilisearch-php < 1.3 and those not add authorization headers to the requests made to your meilisearch instance

This issue would be solved for you if you remove the MEILISEARCH_KEY from your env vars. I posted a comment on the PR of the meilisearch/meilisearch-php repo.

This issue would be solved for you if you remove the MEILISEARCH_KEY from your env vars.

Thanks for the quick reply, @mmachatschek! This solves my problem.

@vintagesucks thanks again for raising this issue. meilisearch-php v1.4.1 was released fixing this breaking change