-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Core decompress body #18581
Core decompress body #18581
Conversation
This pull request is protected by Check Enforcer. What is Check Enforcer?Check Enforcer helps ensure all pull requests are covered by at least one check-run (typically an Azure Pipeline). When all check-runs associated with this pull request pass then Check Enforcer itself will pass. Why am I getting this message?You are getting this message because Check Enforcer did not detect any check-runs being associated with this pull request within five minutes. This may indicate that your pull request is not covered by any pipelines and so Check Enforcer is correctly blocking the pull request being merged. What should I do now?If the check-enforcer check-run is not passing and all other check-runs associated with this PR are passing (excluding license-cla) then you could try telling Check Enforcer to evaluate your pull request again. You can do this by adding a comment to this pull request as follows: What if I am onboarding a new service?Often, new services do not have validation pipelines associated with them, in order to bootstrap pipelines for a new service, you can issue the following command as a pull request comment: |
/azp run python - translation - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run python - translation - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run python - search - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run python - keyvault - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run python - tables - tests |
/azp run python - translation - tests |
/azp run python - search - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
1 similar comment
Azure Pipelines successfully started running 1 pipeline(s). |
I suspect that @iscai-msft is (or should be) interested in this discussion. |
try: | ||
decoded = content.decode('utf-8') | ||
assert False | ||
except UnicodeDecodeError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this raises because we couldn't decompress because no header way found - is that right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because there is no encoding header, we will not try to decompress it.
Here raises error because it fails to decode a compressed stream.
request = client.get(url) | ||
pipeline_response = await client._pipeline.run(request, stream=True) | ||
response = pipeline_response.http_response | ||
data = response.stream_download(client._pipeline, decompress=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the header that being returned here?
Is it raising because the header says it's gzip, but the content itself doesn't match?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right.
In this scenario, there is an encoding header and we pass in decompress=True. We will try to decompress the stream which is not in correct format. So the decompression will fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this failing because the decompression algorithm mismatches the header? Or because the content itself mismatches the header?
I'm wondering because it's a zlib error, but the test name indicates a 'plain' content header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With encoding header "gzip" we will try to use "gzip" algorithm to decompress the stream.
But the content of the stream itself is not compressed (it is plain text).
What happens here is we try to decompress an un-compressed stream so we fail to decompress.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha - perfect!
python - autorest - pr failure is known. |
/azp run python - autorest - pr |
Azure Pipelines successfully started running 1 pipeline(s). |
try: | ||
auto_decompress = self.session.auto_decompress # type: ignore | ||
except AttributeError: | ||
auto_decompress = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a comment as to why we need this. I know I would be confused unless I knew the history...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
zlib_mode = 16 + zlib.MAX_WBITS if enc == "gzip" else zlib.MAX_WBITS | ||
decompressor = zlib.decompressobj(wbits=zlib_mode) | ||
body = decompressor.decompress(self._body) | ||
return body |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do have some concerns about us not caching the decompressed body. Because we only need it once, right? Do we have any other access to self._body
that requires us to keep the compressed data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't expect (as least I did not see) users need to get body twice.
If you want, we can update the code like:
if enc in ("gzip", "deflate"):
if self._decompressed_body:
return self._decompressed_body
import zlib
zlib_mode = 16 + zlib.MAX_WBITS if enc == "gzip" else zlib.MAX_WBITS
decompressor = zlib.decompressobj(wbits=zlib_mode)
self._decompressed_body = decompressor.decompress(self._body)
return self._decompressed_body
return self._body
But to be honest, I don't see lots of value for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The don't need to get the body more than once. And it would not be clear to me that getting the body and then the text will decompress the body twice.
I don't think we need to keep the compressed data around once it has been decompressed, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds fair. Updated. :)
zlib_mode = 16 + zlib.MAX_WBITS if enc == "gzip" else zlib.MAX_WBITS | ||
decompressor = zlib.decompressobj(wbits=zlib_mode) | ||
self._decompressed_body = decompressor.decompress(self._body) | ||
return self._decompressed_body |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest keeping a single copy of the body around. Unless you still need the compressed version for some reason...
ComputeRP 2022-03-01 REST API release (Azure#17988) * new API version set up * update mistakes * move extended location to common * update other readme files for sdk languages * Adding UltraSSDcapability properties in dedicated host resource (Azure#18076) * Added diffDiskSettings property as part of Swagger changes needed for Ephemeral VM\VMSS * updated comment * updated swagger specs for diffdisksettings property * updated swagger spec comments for diff disk settings [property * added example to create Diff OS disk scaleset * updated 2018-10-01 version specs with diffdisk property * added example file for creating VM with diffdisksettings property * updated swagger changes for reimage operation in single vm * update examples * udpated examples * fixed validation errors * updated comments for reimage operation documentation * Updated examples and documentation for APIs in swagger * updated examples as per review comments * updated swagger documentation * updated swagger documentation with zone details in the sku example * updated swagger documentation and reverted the breaking changes * updated examples as per swagger model * updated swagger to remove the model validation errors for existing examples where we are passing read only parameter in the request * updated swagger * updated swagger * Added new property in DiffDiskSettings * updated swagger spec * udpated swagger * updated swagger spec * updated code * updated code * udpated swagger * updated code * updated swagger documentation for DiffDiskPlacement * updated code * updated documentation * updated code * updated swagger * updated swagger * updated swagger * updated code * updated code * updated example json * updated swagger changes * updated swagger * Updating minor documentation for the changes checked in PR: 18076 (Azure#18528) * Added diffDiskSettings property as part of Swagger changes needed for Ephemeral VM\VMSS * updated comment * updated swagger specs for diffdisksettings property * updated swagger spec comments for diff disk settings [property * added example to create Diff OS disk scaleset * updated 2018-10-01 version specs with diffdisk property * added example file for creating VM with diffdisksettings property * updated swagger changes for reimage operation in single vm * update examples * udpated examples * fixed validation errors * updated comments for reimage operation documentation * Updated examples and documentation for APIs in swagger * updated examples as per review comments * updated swagger documentation * updated swagger documentation with zone details in the sku example * updated swagger documentation and reverted the breaking changes * updated examples as per swagger model * updated swagger to remove the model validation errors for existing examples where we are passing read only parameter in the request * updated swagger * updated swagger * Added new property in DiffDiskSettings * updated swagger spec * udpated swagger * updated swagger spec * updated code * updated code * udpated swagger * updated code * updated swagger documentation for DiffDiskPlacement * updated code * updated documentation * updated code * updated swagger * updated swagger * updated swagger * updated code * updated code * updated example json * updated swagger changes * updated swagger * udpated swagger * Merged the intent from origin (Azure#18159) * fix naming convention error =s * new API version set up * update mistakes * move extended location to common * update other readme files for sdk languages * Adding UltraSSDcapability properties in dedicated host resource (Azure#18076) * Added diffDiskSettings property as part of Swagger changes needed for Ephemeral VM\VMSS * updated comment * updated swagger specs for diffdisksettings property * updated swagger spec comments for diff disk settings [property * added example to create Diff OS disk scaleset * updated 2018-10-01 version specs with diffdisk property * added example file for creating VM with diffdisksettings property * updated swagger changes for reimage operation in single vm * update examples * udpated examples * fixed validation errors * updated comments for reimage operation documentation * Updated examples and documentation for APIs in swagger * updated examples as per review comments * updated swagger documentation * updated swagger documentation with zone details in the sku example * updated swagger documentation and reverted the breaking changes * updated examples as per swagger model * updated swagger to remove the model validation errors for existing examples where we are passing read only parameter in the request * updated swagger * updated swagger * Added new property in DiffDiskSettings * updated swagger spec * udpated swagger * updated swagger spec * updated code * updated code * udpated swagger * updated code * updated swagger documentation for DiffDiskPlacement * updated code * updated documentation * updated code * updated swagger * updated swagger * updated swagger * updated code * updated code * updated example json * updated swagger changes * updated swagger * Updating minor documentation for the changes checked in PR: 18076 (Azure#18528) * Added diffDiskSettings property as part of Swagger changes needed for Ephemeral VM\VMSS * updated comment * updated swagger specs for diffdisksettings property * updated swagger spec comments for diff disk settings [property * added example to create Diff OS disk scaleset * updated 2018-10-01 version specs with diffdisk property * added example file for creating VM with diffdisksettings property * updated swagger changes for reimage operation in single vm * update examples * udpated examples * fixed validation errors * updated comments for reimage operation documentation * Updated examples and documentation for APIs in swagger * updated examples as per review comments * updated swagger documentation * updated swagger documentation with zone details in the sku example * updated swagger documentation and reverted the breaking changes * updated examples as per swagger model * updated swagger to remove the model validation errors for existing examples where we are passing read only parameter in the request * updated swagger * updated swagger * Added new property in DiffDiskSettings * updated swagger spec * udpated swagger * updated swagger spec * updated code * updated code * udpated swagger * updated code * updated swagger documentation for DiffDiskPlacement * updated code * updated documentation * updated code * updated swagger * updated swagger * updated swagger * updated code * updated code * updated example json * updated swagger changes * updated swagger * udpated swagger * Merged the intent from origin (Azure#18159) * fix naming convention error =s * fix issues from Azure/azure-rest-api-specs#18159 * Adding Identity to VirtualMachineScaleSetVM (Azure#18295) * init * PR comment * [Crash Consistent RestorePoints] Making consistencyMode input parameter for RestorePoint (Azure#18165) * removing readonly for consistencymode * small spell correction 2.1 * [RestorePoints] Fixing instanceView (Azure#18592) * fixing instance view 20220301instanceviewfix branch 1.1 * adding objects 2.1 * VMSS Flex Disk deleteOption changes (Azure#18433) * disk delete option for vmss flex * prettier changes * update parameters Co-authored-by: Kimberly Yip Chang <kiyipcha@microsoft.com> * Fix vm extension location bug (Azure#18487) * fix * fix lint issue * Update properties for VMApps, CRP (Azure#18609) * saving work * ran prettier * fix LintDiff, SpellCheck * reverted changes made to gallery.json. The changes to gallery.json will be part of separate PR. * GuestPatching: Adding AutomaticByPlatformSettings (in VMSS and VM model) and useRollingUpgradePolicy (in VMSS model) properties (Azure#18581) * GuestPatching: Adding AutomaticByPlatofrmSettings within Linux and Windows Patch settings for VM and VMSS model * Updating examples related to AutomaticByPlatformSettings property in PatchSettings for VM and VMSS model * Adding useRollingUpgradePolicy property to automaticOSUpgradePolicy for VMSS and other minor changes for AutomaticByPlatfrom settings * Addressing PR feedback * Addressing PR feedback #2 * Renaming reboot reference for windows and linux automaticbyplatform patch settings - reboot settings * Resolving errors reported on the PR by Avocado and LintDiff * add architecture added in last version * fix CI failures * added PremiumV2_LRS (Azure#18809) * Update dedicatedHost.json * fix example name to keep it consistent with others * Update computeRPCommon.json Co-authored-by: hari-bodicherla <43284966+hari-bodicherla@users.noreply.github.com> Co-authored-by: aspand <45955504+aspand@users.noreply.github.com> Co-authored-by: kamusta-msft <56413142+kamusta-msft@users.noreply.github.com> Co-authored-by: prchin <101265062+prchin@users.noreply.github.com> Co-authored-by: Kimberly Yip Chang <kimberlyyipc@gmail.com> Co-authored-by: Kimberly Yip Chang <kiyipcha@microsoft.com> Co-authored-by: Bhaskar Brahma <bhbrahma@microsoft.com> Co-authored-by: Rajasi Rane <56841542+rane-rajasi@users.noreply.github.com> Co-authored-by: PushyaragY <100753036+PushyaragY@users.noreply.github.com>
No description provided.