Revert "PYTHON-2048 Improve error message for bulk_write failures due to unsu…"

This reverts commit 4470309fa0.
This commit is contained in:
Steven Silvester 2024-04-17 13:24:41 -05:00 committed by GitHub
parent 5f372ba63a
commit 23ca8ad2be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -149,19 +149,8 @@ def _merge_command(
def _raise_bulk_write_error(full_result: _DocumentOut) -> NoReturn:
"""Raise a BulkWriteError from the full bulk api result."""
# retryWrites on MMAPv1 should raise an actionable error.
if full_result["writeErrors"]:
full_result["writeErrors"].sort(key=lambda error: error["index"])
err = full_result["writeErrors"][0]
code = err["code"]
msg = err["errmsg"]
if code == 20 and msg.startswith("Transaction numbers"):
errmsg = (
"This MongoDB deployment does not support "
"retryable writes. Please add retryWrites=false "
"to your connection string."
)
raise OperationFailure(errmsg, code, full_result)
raise BulkWriteError(full_result)