fix(search): reindex on a fresh Meilisearch
Deleting a missing <uid>_next index is accepted with 202 and fails inside the task with index_not_found. That error was not treated as not-found, so the first reindex aborted and search stayed unavailable until indexes existed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
58bd14ef38
commit
e250837de9
2 files changed
+33
No files matched your search
@@ -77,6 +77,7 @@ func (m *Meili) wait(ctx context.Context, t taskRef) error {
|
||||
Status string `json:"status"`
|
||||
Error *struct {
|
||||
Message string `json:"message"`
|
||||
Code string `json:"code"`
|
||||
} `json:"error"`
|
||||
}
|
||||
if err := m.do(ctx, http.MethodGet, fmt.Sprintf("/tasks/%d", t.TaskUID), nil, &task); err != nil {
|
||||
@@ -88,6 +89,10 @@ func (m *Meili) wait(ctx context.Context, t taskRef) error {
|
||||
case "failed", "canceled":
|
||||
msg := task.Status
|
||||
if task.Error != nil {
|
||||
// Удаление отсутствующего индекса принимается (202) и падает уже в задаче.
|
||||
if task.Error.Code == "index_not_found" {
|
||||
return fmt.Errorf("%w: task %d: %s", ErrMeiliNotFound, t.TaskUID, task.Error.Message)
|
||||
}
|
||||
msg = task.Error.Message
|
||||
}
|
||||
return fmt.Errorf("meilisearch: task %d: %s", t.TaskUID, msg)
|
||||
|
||||
Reference in new issue
Block a user