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 4 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 4 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

@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.

❌ CI Failures

The following CI checks failed on this PR:

  • Azure.azure-cli — the main CI pipeline failed
  • Azure.azure-cli (Test Homebrew Formula) — the Homebrew formula test failed

Please investigate the failures in the CI run logs and fix the issues, then push a new commit.


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

@a0x1ab

a0x1ab commented Jul 20, 2026

Copy link
Copy Markdown
Member

@copilot the automated CI and live-test review on this PR found failures. Please look into the requested changes here: #33730 (review) and push a fix.


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

Copilot AI commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

@copilot the automated CI and live-test review on this PR found failures. Please look into the requested changes here: #33730 (review) and pu...

Pushed de4bbe4. I hardened the Homebrew CI uninstall step so the job skips brew uninstall azure-cli when the macOS image does not have Azure CLI preinstalled, and kept the same guard in the shared Homebrew test script. The storage regression test still passes; the live-test run on this PR was already green.

@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.

Automated Review — Changes Requested

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

Live test (Tester)

  • Workflow run: https://github.com/Azure/issue-sentinel/actions/runs/29709280743failed
  • Job azdev test --live (PR 33730) failed. Please check the live test output for the az storage fs file download command and fix the underlying issue (log fetch was unavailable due to a transient GitHub API outage, so please re-check the run directly).

CI status (azure-cli, head SHA de4bbe4)

3 checks failed, 23 still pending/in progress at the time of this review:

  1. Test Homebrew Formula — failed: https://github.com/Azure/azure-cli/runs/88252678005
  2. Integration Test against Profiles Python312 — failed: https://github.com/Azure/azure-cli/runs/88251764895
  3. Build Windows MSI x64 — failed: https://github.com/Azure/azure-cli/runs/88251561172

Please investigate these failures (Homebrew formula validation, the Python 3.12 profile integration tests, and the Windows MSI build), along with the live-test failure above, and push a fix. Once the changes are in, CI and the live test will automatically re-run.


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

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