-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[Storage] Fix #32503: az storage file list: Fix listing files when using Oauth without Reader access
#32602
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
base: dev
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.