Skip to content

Commit 76b3f85

Browse files
committed
fix: replace json serialization with to_json for error logging in bulk indexing
1 parent 435db00 commit 76b3f85

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

biothings/hub/dataindex/indexer_task.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import json
21
import logging
32
from collections import namedtuple
43
from enum import Enum
@@ -10,6 +9,7 @@
109

1110
from biothings.utils.es import ESIndex as BaseESIndex
1211
from biothings.utils.loggers import get_logger
12+
from biothings.utils.serializer import to_json
1313

1414
try:
1515
from biothings.utils.mongo import doc_feeder
@@ -93,7 +93,7 @@ def _action(doc):
9393
self.logger.error(error)
9494
self.logger.error("Document ID %s failed: %s", document_id, reason)
9595

96-
serialized_errors = json.dumps(errors, indent=2, default=str)
96+
serialized_errors = to_json(errors, indent=True)
9797
message = (
9898
f"Bulk indexing failed for index '{self.index_name}'. "
9999
f"Elasticsearch responded with errors:\n{serialized_errors}"

0 commit comments

Comments
 (0)