From 02201d24e7c0527459bd00d1a3b740b1abdf93cf Mon Sep 17 00:00:00 2001 From: Noah Stapp Date: Mon, 13 Apr 2026 15:01:52 -0400 Subject: [PATCH] AC review --- pymongo/asynchronous/client_bulk.py | 11 ++++------- pymongo/synchronous/client_bulk.py | 11 ++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/pymongo/asynchronous/client_bulk.py b/pymongo/asynchronous/client_bulk.py index 508b8e41c..015947d7e 100644 --- a/pymongo/asynchronous/client_bulk.py +++ b/pymongo/asynchronous/client_bulk.py @@ -59,6 +59,7 @@ from pymongo.errors import ( InvalidOperation, NotPrimaryError, OperationFailure, + PyMongoError, WaitQueueTimeoutError, ) from pymongo.helpers_shared import _RETRYABLE_ERROR_CODES @@ -563,13 +564,9 @@ class _AsyncClientBulk: error, ConnectionFailure ) and not isinstance(error, (NotPrimaryError, WaitQueueTimeoutError)) - retryable_label_error = ( - hasattr(error, "details") - and isinstance(error.details, dict) - and "errorLabels" in error.details - and isinstance(error.details["errorLabels"], list) - and "RetryableError" in error.details["errorLabels"] - ) + retryable_label_error = isinstance( + error, PyMongoError + ) and error.has_error_label("RetryableError") # Synthesize the full bulk result without modifying the # current one because this write operation may be retried. diff --git a/pymongo/synchronous/client_bulk.py b/pymongo/synchronous/client_bulk.py index e8167bced..1134594ae 100644 --- a/pymongo/synchronous/client_bulk.py +++ b/pymongo/synchronous/client_bulk.py @@ -59,6 +59,7 @@ from pymongo.errors import ( InvalidOperation, NotPrimaryError, OperationFailure, + PyMongoError, WaitQueueTimeoutError, ) from pymongo.helpers_shared import _RETRYABLE_ERROR_CODES @@ -561,13 +562,9 @@ class _ClientBulk: error, ConnectionFailure ) and not isinstance(error, (NotPrimaryError, WaitQueueTimeoutError)) - retryable_label_error = ( - hasattr(error, "details") - and isinstance(error.details, dict) - and "errorLabels" in error.details - and isinstance(error.details["errorLabels"], list) - and "RetryableError" in error.details["errorLabels"] - ) + retryable_label_error = isinstance( + error, PyMongoError + ) and error.has_error_label("RetryableError") # Synthesize the full bulk result without modifying the # current one because this write operation may be retried.