Conversation
… assume SMB share first, if it fails with UnsupportedQueryParameter error, retry assuming NFS share
️✔️AzureCLI-FullTest
|
|
Hi @calvinhzy, |
️✔️AzureCLI-BreakingChangeTest
|
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #32503 where az storage file list fails when using OAuth authentication without Reader access. The fix avoids calling get_share_properties (which requires share-level read access) by using a try-catch approach: it assumes an SMB share first and attempts to list files with extended metadata; if it receives an UnsupportedQueryParameter error, it retries assuming an NFS share without extended metadata.
Key changes:
- Removed the
get_share_properties()call that required elevated permissions - Implemented try/catch logic to attempt SMB listing first, then NFS if needed
- Updated test recordings to reflect the new error-handling flow
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/azure-cli/azure/cli/command_modules/storage/operations/file.py | Refactored list_share_files to use try-catch for protocol detection instead of calling get_share_properties |
| src/azure-cli/azure/cli/command_modules/storage/tests/latest/recordings/test_storage_file_share_nfs_scenario.yaml | Updated test recordings showing UnsupportedQueryParameter error being caught for NFS shares |
| src/azure-cli/azure/cli/command_modules/storage/tests/latest/recordings/test_storage_file_main_oauth_scenario.yaml | Updated test recordings with new timestamps and version information |
Comments suppressed due to low confidence (1)
src/azure-cli/azure/cli/command_modules/storage/operations/file.py:120
- The variable
pagesmay be undefined if an exception other thanUnsupportedQueryParameteris caught and re-raised. When the exception is re-raised at line 116, the code continues to line 118 wherepages.continuation_tokenis accessed, butpageswas only defined inside the try/except blocks and may not exist in the outer scope if the initial try block failed before line 103.
if pages.continuation_token:
logger.warning('Next Marker:')
logger.warning(pages.continuation_token)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Related command
Description
since get_share_properties requires share level read access, skip it, assume SMB share first, if it fails with UnsupportedQueryParameter error, retry assuming NFS share
Testing Guide
History Notes
[Storage] Fix #32503:
az storage file list: Fix listing files when using Oauth without Reader accessThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.