-
Notifications
You must be signed in to change notification settings - Fork 3k
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
az cli incorrect parsing of query "--query "[0].keys(@)" #14972
Comments
thanks for reporting the issue! hi @qwordy could you pls help to have a look? Is this a general issue in query? thanks |
Remove the compute label. --query is a global parameter. |
It looks like you are running this command in Command Prompt, but I can't reproduce it D:\cli>az vm list --query "[0].keys(@)"
[
"location",
"tags",
"plan",
...
] May I know what terminal you are using? By the way, there are some known quoting issues with PowerShell. But when I ran this command, it is weird that the command is actually invoked twice, one without the > az vm list --debug --query "[0].keys(@)"
Command arguments: ['vm', 'list', '--debug', '--query', '[0].keys(@']
...
az vm list: error: argument --query: invalid jmespath_type value: '[0].keys(@'
...
Command arguments: ['vm', 'list', '--debug', '--query', '[0].keys(@)']
...
[
"id",
"name",
"type",
"location",
... I am not sure why this happens, but anyway in PowerShell the correct way to run this command is to quote az vm list --query '"[0].keys(@)"'
# or
az --% vm list --query "[0].keys(@)" |
Indeed I am using Powershell (version 5.1.19041.1 running in Windows Terminal 1.2.2381.0). |
At least now I have an idea why the variant with the extra space I assumed any character would do, but the real difference seems to be that the whitespace prevents prevents PowerShell from stripping the quotes as mentioned in Quoting issues with PowerShell. This is confirmed by the fact that the following variants of the command work as expected (in PowerShell):
Well - live and learn. |
Glad to know the issue is solved. 😊 @houk-ms, maybe we can improve the error message for |
sure, that make sense. while if it only happens on powershell, maybe better if we can show the hints only to powershell users |
Tracked by #15529 |
This is autogenerated. Please review and update as needed.
Describe the bug
I get an error message (see below) when I issue the following command. The command should output the structure of the json data.
Command Name
az vm list -d --query "[0].keys(@)"
Errors:
As you may notice in the error message the closing parenthesis of the query is missing.
So I reissued the slightly modified command with an extra space after the closing parenthesis:
az vm list -d --query "[0].keys(@) "
Et Voilà:
To Reproduce:
See above.
Expected Behavior
The command should output the keys of the json describing the vm.
Environment Summary
Additional Context
The text was updated successfully, but these errors were encountered: