question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

az cli incorrect parsing of query "--query "[0].keys(@)"

See original GitHub issue

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:

az vm list: error: argument --query: invalid jmespath_type value: '[0].keys(@'
usage: az vm list [-h] [--verbose] [--debug] [--only-show-errors]
                  [--output {json,jsonc,yaml,yamlc,table,tsv,none}]
                  [--query JMESPATH] [--subscription _SUBSCRIPTION]
                  [--resource-group RESOURCE_GROUP_NAME] [--show-details]
To learn more about [--query JMESPATH] usage in AzureCLI, visit https://aka.ms/CLIQuery

C:\>echo Failed to load python executable.
Failed to load python executable.

C:\>exit /b 1

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à:

[
  "location",
  "tags",
 ... skipped for prevety
 "privateIps",
  "macAddresses",
  "resourceGroup"
]

To Reproduce:

See above.

Expected Behavior

The command should output the keys of the json describing the vm.

Environment Summary

Windows-10-10.0.19041-SP0
Python 3.6.8
Installer: MSI

azure-cli 2.11.0 *

Extensions:
interactive 0.4.4

Additional Context

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ralfkretcommented, Sep 7, 2020

At least now I have an idea why the variant with the extra space az vm list --query "[0].keys(@) " worked.

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):

az vm list --query " [0].keys(@)"
az vm list --query "[0].keys( @ )"

Well - live and learn.

0reactions
qwordycommented, Sep 7, 2020

I can’t run this command and got error #15064. @qwordy

It is a service issue after my investigation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JMESPath query command results with Azure CLI
The Azure CLI uses the --query argument to execute a JMESPath query on the results of commands. Learn how to use the features...
Read more >
AZ CLI and JMESPath queries
Here is one example that demonstrates how to check if the key vault exists and how to create it if it doesn't. Focus...
Read more >
AZ CLI query filter on multiple properties using && - ...
I am trying to create an az cli query that can evaluate if I am logged into the correct tenant and subscription.
Read more >
JMESPATH queries
The Azure CLI uses the industry standard JMESPATH query format that is used not only by the ... Here is some example JSON...
Read more >
parse_url - Manual
parse_url(string $url , int $component = -1): int|string|array|null|false ... As of PHP 8.0.0, parse_url() distinguishes absent and empty queries and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found