meilisearch / meilisearch/meilisearch-python

Raise exception when a task fails when using `wait_for` method

Open
#747 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted stale
Dominant language
Python
Stars
602
Forks
118
Avg merge
4h 44m
Merged PRs (30d)
1

Description

Right now, there is no way to easily raise an exception for a failed task. When I use the built-in "wait for task" functionality, I'd like a way to get it to automatically raise an exception if the task I've waited for did not succeed. This could happen automatically as part of calling the method, or it could take the form of a `raise_for_status()` method (like what the `requests` library exposes on response objects).

The latter suggestion is complicated by the fact that right now, not all methods that return task data return the actual `Task` object. Some of them return dictionaries while others return instances of the `Task` class. I think this inconsistency would need to be addressed at the same time.

It is worth noting that the `MeilisearchApiError` exception contains very similar fields to what is available in the `error` data in the API task data. Unfortunately it also contains other information that make it difficult to easily re-use for the purpose I've described (a "failed task" exception).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the wait_for method and the other methods that return task data, comparing dictionary results with Task instances. Review the existing MeilisearchApiError fields and task error data; done means the behavior for failed tasks and the return-type inconsistency are resolved consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.