Skip to content

[Storage] az storage fs file download: Stream ADLS Gen2 downloads to avoid content-encoding decode failures#33730

Draft
a0x1ab with Copilot wants to merge 3 commits into
devfrom
copilot/fix-deflate-decompression-error
Draft

[Storage] az storage fs file download: Stream ADLS Gen2 downloads to avoid content-encoding decode failures#33730
a0x1ab with Copilot wants to merge 3 commits into
devfrom
copilot/fix-deflate-decompression-error

Conversation

Copilot AI commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Related command
az storage fs file download

Description
az storage fs file download can fail on ADLS Gen2 files when the response carries Content-Encoding: deflate; upload/list/show paths succeed, but download trips the SDK readall() decode path.

  • Download path
    • Switch ADLS file download from buffered readall() to streamed readinto(stream).
    • Aligns storage fs file download with the existing stream-to-file pattern used elsewhere in storage download flows.
  • Effect
    • Avoids client-side content-decoding failures during download.
    • Preserves destination path resolution and overwrite behavior.
with open(destination_path, 'wb') as stream:
    download = client.download_file(timeout=timeout)
    download.readinto(stream)
  • Regression coverage
    • Add a focused storage unit test that verifies the ADLS helper writes via readinto() and does not depend on readall().

Testing Guide
Example reproduction path:

az storage fs file download \
  --file-system <fs> \
  --path 'testdata/special_character_test/ファイル_japanese_日本語.txt' \
  --destination <local-path> \
  --account-name <account>

Expected: file is written successfully even when the service response includes Content-Encoding.

History Notes
[Storage] az storage fs file download: Stream ADLS Gen2 downloads to avoid content-encoding decode failures


This checklist is used to make sure that common guidelines for a pull request are followed.

@azure-client-tools-bot-prd

Copy link
Copy Markdown
Validation for Azure CLI Full Test Starting...

Thanks for your contribution!

@azure-client-tools-bot-prd

Copy link
Copy Markdown
Validation for Breaking Change Starting...

Thanks for your contribution!

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI changed the title [WIP] Fix deflate decompression error on ADLS Gen2 file download [Storage] az storage fs file download: Stream ADLS Gen2 downloads to avoid content-encoding decode failures Jul 15, 2026
Copilot AI requested a review from a0x1ab July 15, 2026 02:14
@azure-client-tools-agent

Copy link
Copy Markdown

Live test results — azdev test --live --series (changed test files only)

PASS

Selectors: test_storage_fs_file_operations (module)
PR head ref: copilot/fix-deflate-decompression-error
PR head sha: c76ba1f5d9a2138dacba78f3a094fa91078d2d5f
PR base ref: dev
New test files in PR: true

Changed test files run
src/azure-cli/azure/cli/command_modules/storage/tests/latest/test_storage_fs_file_operations.py

New test files
src/azure-cli/azure/cli/command_modules/storage/tests/latest/test_storage_fs_file_operations.py

Workflow run: https://github.com/Azure/issue-sentinel/actions/runs/29383646373

Last 80 lines of azdev output

=============
| Run Tests |
=============


=====================
| Discovering Tests |
=====================

/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/identity/tests/latest/test_identity.py:18: SyntaxWarning: invalid escape sequence '\{'
  'resource_restriction_compute': '\{"providers":\["Microsoft.Compute"\]\}',
/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/identity/tests/latest/test_identity.py:19: SyntaxWarning: invalid escape sequence '\{'
  'resource_restriction_empty': '\{"providers":\[\]\}'
/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:13533: SyntaxWarning: invalid escape sequence '\]'
  self.cmd('vmss application set -g {rg} -n {vmss} --app-version-ids {vid1} {vid2} --enable-automatic-upgrade True\]', checks=[

test index updated: /home/runner/.azdev/env_config/home/runner/work/issue-sentinel/issue-sentinel/.venv/test_index/latest.json

Test on modules: test_storage_fs_file_operations

WARNING: RUNNING TESTS LIVE
The tests are set to run against current profile "latest"
============================= test session starts ==============================
platform linux -- Python 3.12.13, pytest-9.1.1, pluggy-1.6.0 -- /home/runner/work/issue-sentinel/issue-sentinel/.venv/bin/python
cachedir: .pytest_cache
rootdir: /home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli
plugins: forked-1.6.0, xdist-3.8.0
collecting ... collected 1 item

azure-cli/src/azure-cli/azure/cli/command_modules/storage/tests/latest/test_storage_fs_file_operations.py::TestStorageFsFileOperations::test_download_file_streams_content_to_destination PASSED [100%]

- generated xml file: /home/runner/work/issue-sentinel/issue-sentinel/test-output/results.xml -
============================== 1 passed in 0.13s ===============================

Posted by agent-assist live-test workflow.

@azure-client-tools-agent azure-client-tools-agent Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Review: All checks passed

Live test: Run #29383646373success
CI checks: 1 passed, 0 failed, 0 pending

Summary

PR #33730 fixes az storage fs file download failures on ADLS Gen2 files with Content-Encoding: deflate by switching from buffered readall() to streamed readinto(stream). This aligns with the existing stream-to-file pattern used elsewhere in storage downloads.

All checks are green and the live test completed successfully. This PR is ready for maintainer review and merge.


Posted by agent-assist (autonomous bug-fix pipeline).

@yonzhan

yonzhan commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Storage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

az storage fs file download fails with content-encoding: deflate decode error on ADLS Gen2

3 participants