Skip to content

More readable error when empty doc list passed #584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions meilisearch/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from meilisearch.models.index import IndexStats
from meilisearch.models.task import Task, TaskInfo, TaskResults
from meilisearch.task import get_task, get_tasks, wait_for_task
from meilisearch.errors import MeiliSearchError


# pylint: disable=too-many-public-methods
Expand Down Expand Up @@ -350,6 +351,8 @@ def add_documents(
An error containing details about why Meilisearch can't process your request. Meilisearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors
"""
url = self._build_url(primary_key)
if not documents:
raise MeiliSearchError("An empty document list was provided. No request will be sent to the Meilisearch API")
add_document_task = self.http.post(url, documents)
return TaskInfo(**add_document_task)

Expand Down