Skip to content

Commit 435db00

Browse files
committed
fix: improve error handling in bulk indexing with detailed logging
1 parent d430975 commit 435db00

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

biothings/hub/dataindex/indexer_task.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import logging
23
from collections import namedtuple
34
from enum import Enum
@@ -92,8 +93,12 @@ def _action(doc):
9293
self.logger.error(error)
9394
self.logger.error("Document ID %s failed: %s", document_id, reason)
9495

95-
self.logger.warning("Discovered errors during the bulk index task. Defaulting to 0 indexed documents")
96-
return 0
96+
serialized_errors = json.dumps(errors, indent=2, default=str)
97+
message = (
98+
f"Bulk indexing failed for index '{self.index_name}'. "
99+
f"Elasticsearch responded with errors:\n{serialized_errors}"
100+
)
101+
raise helpers.BulkIndexError(message, errors) from e
97102

98103
# NOTE
99104
# Why doesn't "mget", "mexists", "mindex" belong to the base class?

0 commit comments

Comments
 (0)