Skip to content

[Storage] Reduce debug-time import failures in az storage container list#33729

Draft
a0x1ab with Copilot wants to merge 3 commits into
devfrom
copilot/az-storage-container-list-failure-fix
Draft

[Storage] Reduce debug-time import failures in az storage container list#33729
a0x1ab with Copilot wants to merge 3 commits into
devfrom
copilot/az-storage-container-list-failure-fix

Conversation

Copilot AI commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Related command
az storage container list

Description
az storage container list --account-name ... --auth-mode login worked functionally but emitted misleading debug tracebacks (azure.mgmt.storage.blob/file module import failures) during command loading. This change removes those noisy/incorrect import paths from storage argument/completer setup and keeps behavior stable when legacy track1 SDK classes are unavailable.

  • Root cause addressed

    • storage/_params.py was resolving legacy data-plane classes (BaseBlobService, FileService) via self.get_sdk(...), which routes through profile/mgmt resolution and triggers azure.mgmt.storage.* import probes in debug logs.
  • Changes in command setup

    • Switched legacy class resolution in storage/_params.py to safe direct imports (import_module(...)) with graceful None fallback.
    • Updated the remaining legacy file SAS path that used self.get_sdk('file.fileservice#FileService') to the same safe import pattern.
  • Changes in completer behavior

    • Added guardrails in storage/completers.py:
      • return empty completions when legacy FileService is unavailable.
      • return empty completions when service class input is None (name and ACL completers).
  • Focused regression coverage

    • Added unit tests in storage/tests/latest/test_storage_validators.py for:
      • empty completion behavior when legacy service classes are unavailable.
      • guarded path for file path completer fallback.
def _get_legacy_storage_data_plane_sdk(module_name, class_name):
    try:
        return getattr(import_module(module_name), class_name)
    except (ImportError, AttributeError):
        return None

Testing Guide

  • Repro command from issue:
    • az storage container list --account-name <account> --auth-mode login --debug
  • What to verify:
    • command no longer emits ModuleNotFoundError: No module named 'azure.mgmt.storage.blob/file' during argument/command table load.

History Notes
[Storage] az storage container list: Avoid debug-time azure.mgmt.storage.blob/file import tracebacks by using safe legacy data-plane class resolution in argument/completer setup.


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 az storage container list failure [Storage] Reduce debug-time import failures in az storage container list Jul 15, 2026
Copilot AI requested a review from a0x1ab July 15, 2026 01:48
@azure-client-tools-agent

Copy link
Copy Markdown

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

⚠️ NO TESTS SELECTED — changed test files did not resolve to runnable tests

Selectors: test_storage_validators (module)
PR head ref: copilot/az-storage-container-list-failure-fix
PR head sha: 881eeea32c7d02b4da5ab3d04ae19a04bbdf87b3
PR base ref: dev
New test files in PR: false

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

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

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=[
WARNING: 'test_storage_validators' exists in both 'storage' and 'core'. Resolve using `storage.test_storage_validators` or `core.test_storage_validators`Duplication exists in: 
	/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/storage/tests/latest/test_storage_validators.py
	/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli-core/azure/cli/core/tests/test_storage_validators.py


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_validators

WARNING: RUNNING TESTS LIVE
WARNING: 'test_storage_validators' not found. If newly added, re-run with --discover
WARNING: No tests selected to run.

Posted by agent-assist live-test workflow.

@a0x1ab

a0x1ab commented Jul 15, 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: #33729 (review) and push a fix.


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

@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 — Action Needed

PR head SHA: 881eeea32c7d02b4da5ab3d04ae19a04bbdf87b3

1. Live test failed (live-test.yml / azdev test --live --series)

The live-test run for the changed test file did not execute any tests:

WARNING: 'test_storage_validators' not found. If newly added, re-run with --discover
WARNING: No tests selected to run.

The module name test_storage_validators is ambiguous — it exists in both
azure-cli-core and the storage module:

  • src/azure-cli/azure/cli/command_modules/storage/tests/latest/test_storage_validators.py
  • src/azure-cli-core/azure/cli/core/tests/test_storage_validators.py

azdev reported: WARNING: 'test_storage_validators' exists in both 'storage' and 'core'. Resolve using storage.test_storage_validatorsorcore.test_storage_validators``.

Please make sure your added/changed test file for the storage fix has a
module-qualified/unique test name so azdev test can resolve and run it
without ambiguity (e.g. rename the test module or ensure it doesn't collide
with the identically named module in azure-cli-core), and confirm the new
test actually exercises the storage container list fix.

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

2. CI check failed: Test Homebrew Formula

The Homebrew Formula check failed on this PR:
https://github.com/Azure/azure-cli/runs/87251745936

Please investigate and fix the Homebrew Formula build/test failure (e.g. the
generated formula, versions, or SHA references may need updating for this
change) and push a new commit.


Once both issues above are resolved and pushed, CI and the live test will be
re-evaluated automatically.


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

Copilot AI commented Jul 15, 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: #33729 (review) and pu...

Pushed a fix in bdde209 to address the live-test failure: the new storage completer guard tests were moved from test_storage_validators.py to test_storage_completers.py, eliminating the test_storage_validators selector collision with core while preserving coverage.

I also investigated the Homebrew check context from available check metadata; this update is minimal and should allow CI to re-evaluate on the new commit.

@azure-client-tools-agent

Copy link
Copy Markdown

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

PASS

Selectors: test_storage_completers test_storage_validators (module)
PR head ref: copilot/az-storage-container-list-failure-fix
PR head sha: bdde209ea41d003c33c5006b07bd5f031f2d4bea
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_completers.py
src/azure-cli/azure/cli/command_modules/storage/tests/latest/test_storage_validators.py

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

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

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=[
WARNING: 'test_storage_validators' exists in both 'storage' and 'core'. Resolve using `storage.test_storage_validators` or `core.test_storage_validators`Duplication exists in: 
	/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/storage/tests/latest/test_storage_validators.py
	/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli-core/azure/cli/core/tests/test_storage_validators.py


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_completers, test_storage_validators

WARNING: RUNNING TESTS LIVE
WARNING: 'test_storage_validators' not found. If newly added, re-run with --discover
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 3 items

azure-cli/src/azure-cli/azure/cli/command_modules/storage/tests/latest/test_storage_completers.py::TestStorageCompleters::test_file_path_completer_returns_empty_with_missing_legacy_service PASSED [ 33%]
azure-cli/src/azure-cli/azure/cli/command_modules/storage/tests/latest/test_storage_completers.py::TestStorageCompleters::test_storage_acl_name_completer_returns_empty_with_missing_legacy_service PASSED [ 66%]
azure-cli/src/azure-cli/azure/cli/command_modules/storage/tests/latest/test_storage_completers.py::TestStorageCompleters::test_storage_name_completer_returns_empty_with_missing_legacy_service PASSED [100%]

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

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.

Automated Review Summary

Live test (Tester): ✅ Passed (azdev test --live, reused prior successful run for this head SHA)

CI checks: ✅ All 18 checks passed, 0 failed, 0 pending

This PR looks good from an automated verification standpoint — live test and full CI are green for the current head commit. No further action needed from the agent at this time.


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 container list failure

3 participants