Skip to content

Commit 5ebcfb8

Browse files
committed
_shared
1 parent 507c975 commit 5ebcfb8

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

sdk/storage/azure-storage-queue/azure/storage/queue/_shared/response_handlers.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,14 @@ def process_storage_error(storage_error) -> NoReturn: # type: ignore [misc] # p
9696
)
9797
if not storage_error.response or storage_error.response.status_code in [200, 204]:
9898
raise storage_error
99-
# If it is one of those three then it has been serialized prior by the generated layer.
100-
if isinstance(
99+
# The generated layer now pre-maps 412 (Precondition Failed) responses to typed
100+
# exceptions based on the request's match condition (e.g. ResourceExistsError for
101+
# IfMissing, ResourceNotFoundError for IfPresent). Historically 412 was not
102+
# pre-mapped and always flowed through the error-code mapping below, surfacing as
103+
# ResourceModifiedError. Skip the "already serialized" shortcut for 412 so it is
104+
# re-mapped from x-ms-error-code (ConditionNotMet -> ResourceModifiedError) and the
105+
# public exception type is preserved for users.
106+
if storage_error.response.status_code != 412 and isinstance(
101107
storage_error,
102108
(
103109
PartialBatchErrorException,

0 commit comments

Comments
 (0)