Skip to content

Commit b9e6502

Browse files
PYTHON-4660 Fix AttributeError when accessing error.details in client.bulk_write
1 parent 47b2257 commit b9e6502

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

pymongo/asynchronous/client_bulk.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,8 @@ async def _execute_command(
550550
if result.get("error"):
551551
error = result["error"]
552552
retryable_top_level_error = (
553-
isinstance(error.details, dict)
553+
hasattr(error, "details")
554+
and isinstance(error.details, dict)
554555
and error.details.get("code", 0) in _RETRYABLE_ERROR_CODES
555556
)
556557
retryable_network_error = isinstance(

pymongo/synchronous/client_bulk.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,8 @@ def _execute_command(
548548
if result.get("error"):
549549
error = result["error"]
550550
retryable_top_level_error = (
551-
isinstance(error.details, dict)
551+
hasattr(error, "details")
552+
and isinstance(error.details, dict)
552553
and error.details.get("code", 0) in _RETRYABLE_ERROR_CODES
553554
)
554555
retryable_network_error = isinstance(

0 commit comments

Comments
 (0)