Skip to content

Commit

Permalink
[Storage] Fix logged warning on empty blob download (Azure#26006)
Browse files Browse the repository at this point in the history
  • Loading branch information
jalauzon-msft authored Sep 7, 2022
1 parent 0f8cb30 commit 81ab001
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ def failsafe_deserialize(self, target_obj, data, content_type=None):
try:
return self(target_obj, data, content_type=content_type)
except:
_LOGGER.warning(
_LOGGER.debug(
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
)
return None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ async def upload( # pylint: disable=inconsistent-return-statements
immutability_policy_expiry: Optional[datetime.datetime] = None,
immutability_policy_mode: Optional[Union[str, "_models.BlobImmutabilityPolicyMode"]] = None,
legal_hold: Optional[bool] = None,
transactional_content_crc64: Optional[bytes] = None,
blob_http_headers: Optional[_models.BlobHTTPHeaders] = None,
lease_access_conditions: Optional[_models.LeaseAccessConditions] = None,
cpk_info: Optional[_models.CpkInfo] = None,
Expand Down Expand Up @@ -122,6 +123,9 @@ async def upload( # pylint: disable=inconsistent-return-statements
:type immutability_policy_mode: str or ~azure.storage.blob.models.BlobImmutabilityPolicyMode
:param legal_hold: Specified if a legal hold should be set on the blob. Default value is None.
:type legal_hold: bool
:param transactional_content_crc64: Specify the transactional crc64 for the body, to be
validated by the service. Default value is None.
:type transactional_content_crc64: bytes
:param blob_http_headers: Parameter group. Default value is None.
:type blob_http_headers: ~azure.storage.blob.models.BlobHTTPHeaders
:param lease_access_conditions: Parameter group. Default value is None.
Expand Down Expand Up @@ -218,6 +222,7 @@ async def upload( # pylint: disable=inconsistent-return-statements
immutability_policy_expiry=immutability_policy_expiry,
immutability_policy_mode=immutability_policy_mode,
legal_hold=legal_hold,
transactional_content_crc64=transactional_content_crc64,
blob_type=blob_type,
content_type=content_type,
version=self._config.version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class StorageErrorCode(str, Enum, metaclass=CaseInsensitiveEnumMeta):
COPY_ID_MISMATCH = "CopyIdMismatch"
FEATURE_VERSION_MISMATCH = "FeatureVersionMismatch"
INCREMENTAL_COPY_BLOB_MISMATCH = "IncrementalCopyBlobMismatch"
INCREMENTAL_COPY_OF_ERALIER_VERSION_SNAPSHOT_NOT_ALLOWED = "IncrementalCopyOfEralierVersionSnapshotNotAllowed"
INCREMENTAL_COPY_OF_EARLIER_VERSION_SNAPSHOT_NOT_ALLOWED = "IncrementalCopyOfEarlierVersionSnapshotNotAllowed"
INCREMENTAL_COPY_SOURCE_MUST_BE_SNAPSHOT = "IncrementalCopySourceMustBeSnapshot"
INFINITE_LEASE_DURATION_REQUIRED = "InfiniteLeaseDurationRequired"
INVALID_BLOB_OR_BLOCK = "InvalidBlobOrBlock"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def build_upload_request(
immutability_policy_expiry: Optional[datetime.datetime] = None,
immutability_policy_mode: Optional[Union[str, "_models.BlobImmutabilityPolicyMode"]] = None,
legal_hold: Optional[bool] = None,
transactional_content_crc64: Optional[bytes] = None,
**kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
Expand Down Expand Up @@ -151,6 +152,10 @@ def build_upload_request(
)
if legal_hold is not None:
_headers["x-ms-legal-hold"] = _SERIALIZER.header("legal_hold", legal_hold, "bool")
if transactional_content_crc64 is not None:
_headers["x-ms-content-crc64"] = _SERIALIZER.header(
"transactional_content_crc64", transactional_content_crc64, "bytearray"
)
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
Expand Down Expand Up @@ -673,6 +678,7 @@ def upload( # pylint: disable=inconsistent-return-statements
immutability_policy_expiry: Optional[datetime.datetime] = None,
immutability_policy_mode: Optional[Union[str, "_models.BlobImmutabilityPolicyMode"]] = None,
legal_hold: Optional[bool] = None,
transactional_content_crc64: Optional[bytes] = None,
blob_http_headers: Optional[_models.BlobHTTPHeaders] = None,
lease_access_conditions: Optional[_models.LeaseAccessConditions] = None,
cpk_info: Optional[_models.CpkInfo] = None,
Expand Down Expand Up @@ -725,6 +731,9 @@ def upload( # pylint: disable=inconsistent-return-statements
:type immutability_policy_mode: str or ~azure.storage.blob.models.BlobImmutabilityPolicyMode
:param legal_hold: Specified if a legal hold should be set on the blob. Default value is None.
:type legal_hold: bool
:param transactional_content_crc64: Specify the transactional crc64 for the body, to be
validated by the service. Default value is None.
:type transactional_content_crc64: bytes
:param blob_http_headers: Parameter group. Default value is None.
:type blob_http_headers: ~azure.storage.blob.models.BlobHTTPHeaders
:param lease_access_conditions: Parameter group. Default value is None.
Expand Down Expand Up @@ -821,6 +830,7 @@ def upload( # pylint: disable=inconsistent-return-statements
immutability_policy_expiry=immutability_policy_expiry,
immutability_policy_mode=immutability_policy_mode,
legal_hold=legal_hold,
transactional_content_crc64=transactional_content_crc64,
blob_type=blob_type,
content_type=content_type,
version=self._config.version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ def failsafe_deserialize(self, target_obj, data, content_type=None):
try:
return self(target_obj, data, content_type=content_type)
except:
_LOGGER.warning(
_LOGGER.debug(
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
)
return None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ def failsafe_deserialize(self, target_obj, data, content_type=None):
try:
return self(target_obj, data, content_type=content_type)
except:
_LOGGER.warning(
_LOGGER.debug(
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
)
return None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ def failsafe_deserialize(self, target_obj, data, content_type=None):
try:
return self(target_obj, data, content_type=content_type)
except:
_LOGGER.warning(
_LOGGER.debug(
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
)
return None
Expand Down

0 comments on commit 81ab001

Please sign in to comment.