Azure / Azure/azure-cli

az interactive gets stuck in error mode after the first failed attempt to use sort_by

Open
#14,828 2 comments 0 reactions 2 assignees Claimed by @bebound View on GitHub
act-codegen-extensibility-squad customer-reported feature-request Interactive Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### **This is autogenerated. Please review and update as needed.**

While developing command lines with complex query content (sort_by, filtering, and column renaming), you will, of course, make errors trying to interpret what is the correct query syntax for your situation. az interactive has a tendency to have an error during this time become sticky, in that any attempt to correct the problem will continue to see the same error on subsequent attempts. You have to exit az interactive and restart when this occurs.

**Command Name**
I don't think it is any specific command, but rather the JMESPath query processor that has the error. My command was:

**Errors:**
You can see the problem in this output from the az interactive session - I had a working slimmed down command that finally worked, and I wanted to get all the columns I had before the sort_by was added. I got an error, and then got the same error as I attempted to remove parts of the query to see if I could get it to work. Note that even the exit command got the same error before terminating the program. Also notice that the command lines are truncated due to the way az interactive displays them (I copied/pasted the window output). The error seems related to not having adjusted the sort key to the renamed value (tag.priority was renamed to A06Priority, but the sort key was left as &tag.priority). That triggered the lockup.

Here is the full working query:
az network asg list --query "sort_by([?tags.vnet == 'test-eastus'].{A01Name:name,A02Group:resourceGroup,A03Location:location,A04Vnet:tags.vnet,A05Port:tags.port,A06Priority:tags.priority,A07Domain:tags.domain,A08Lockstate:tags.lockState},&A06Priority)" -o table

az>> az network asg list --query "sort_by([?tags.vnet == 'test-eastus'].{name:name,rg:resourceGroup,priority:tags.priority},&priority)" -o table
Name Priority Rg
------------------------- ---------- ----------
test-eastus-http 201 cto-common
test-eastus-https 202 cto-common
test-eastus-RDP 203 cto-common
test-eastus-SSH 204 cto-common
test-eastus-oracle 205 cto-common
test-eastus-postgres 206 cto-common
test-eastus-rabbit 207 cto-common
test-eastus-wac 208 cto-common
test-eastus-http8080 209 cto-common
test-eastus-https8443 210 cto-common
test-eastus-cockpit 211 cto-common
test-useast-NFS 212 cto-common
test-eastus-http8000 213 cto-common
test-eastus-http8081 214 cto-common
test-eastus-ignite 215 cto-common
test-eastus-zookeeper 216 cto-common
test-eastus-KepwareConfig 217 cto-common
test-eastus-http8085 218 cto-common
tus'].{A01Name:name,A02Group:resourceGroup,A03Location:location,A04Vnet:tags.vnet,A05Port:tags.port,A06Priority:tags.priority,A07Domain:tags.domain,A08Lockstate:tags.lockState}

Invalid jmespath query supplied for `--query`:
In function sort_by(), invalid type for value: OrderedDict([('A01Name', 'test-eastus-cockpit'), ('A02Group', 'cto-common'), ('A03Location', 'eastus'), ('A04Vnet', 'test-eastus'), ('A05Port', '9090'), ('A06Priority', '211'), ('A07Domain', 'Azure-Mgmt'), ('A08Lockstate', 'locked')]), expected one of: ['string', 'number'], received: "null"
To learn more about --query, please visit: https://docs.microsoft.com/cli/azure/query-azure-cli?view=azure-cli-latest
2Group:resourceGroup,A03Location:location,A04Vnet:tags.vnet,A05Port:tags.port,A06Priority:tags.priority,A07Domain:tags.domain,A08Lockstate:tags.lockState},&A06priority)" -o tab

Invalid jmespath query supplied for `--query`:
In function sort_by(), invalid type for value: OrderedDict([('A01Name', 'test-eastus-cockpit'), ('A02Group', 'cto-common'), ('A03Location', 'eastus'), ('A04Vnet', 'test-eastus'), ('A05Port', '9090'), ('A06Priority', '211'), ('A07Domain', 'Azure-Mgmt'), ('A08Lockstate', 'locked')]), expected one of: ['string', 'number'], received: "null"
To learn more about --query, please visit: https://docs.microsoft.com/cli/azure/query-azure-cli?view=azure-cli-latest
oup:resourceGroup,A03Location:location,A04Vnet:tags.vnet,A05Port:tags.port,A06Priority:tags.priority,A07Domain:tags.domain,A08Lockstate:tags.lockState},&tags.priority)" -o tabl

Invalid jmespath query supplied for `--query`:
In function sort_by(), invalid type for value: OrderedDict([('A01Name', 'test-eastus-cockpit'), ('A02Group', 'cto-common'), ('A03Location', 'eastus'), ('A04Vnet', 'test-eastus'), ('A05Port', '9090'), ('A06Priority', '211'), ('A07Domain', 'Azure-Mgmt'), ('A08Lockstate', 'locked')]), expected one of: ['string', 'number'], received: "null"
To learn more about --query, please visit: https://docs.microsoft.com/cli/azure/query-azure-cli?view=azure-cli-latest
astus'].{name:name,rg:resourceGroup,A01priority:tags.priority}" -o table

Invalid jmespath query supplied for `--query`:
In function sort_by(), invalid type for value: OrderedDict([('A01Name', 'test-eastus-cockpit'), ('A02Group', 'cto-common'), ('A03Location', 'eastus'), ('A04Vnet', 'test-eastus'), ('A05Port', '9090'), ('A06Priority', '211'), ('A07Domain', 'Azure-Mgmt'), ('A08Lockstate', 'locked')]), expected one of: ['string', 'number'], received: "null"
To learn more about --query, please visit: https://docs.microsoft.com/cli/azure/query-azure-cli?view=azure-cli-latest
p:resourceGroup,A03Location:location,A04Vnet:tags.vnet,A05Port:tags.port,A06Priority:tags.priority,A07Domain:tags.domain,A08Lockstate:tags.lockState},&A06Priority)" -o table

Invalid jmespath query supplied for `--query`:
In function sort_by(), invalid type for value: OrderedDict([('A01Name', 'test-eastus-cockpit'), ('A02Group', 'cto-common'), ('A03Location', 'eastus'), ('A04Vnet', 'test-eastus'), ('A05Port', '9090'), ('A06Priority', '211'), ('A07Domain', 'Azure-Mgmt'), ('A08Lockstate', 'locked')]), expected one of: ['string', 'number'], received: "null"
To learn more about --query, please visit: https://docs.microsoft.com/cli/azure/query-azure-cli?view=azure-cli-latest
query "sort_by([?A04Vnet == 'test-eastus'].{A01Name:name,A02Group:resourceGroup,A03Location:location,A04Vnet:tags.vnet,A05Port:tags.port,A06Priority:tags.priority,A07Domain:tag

Invalid jmespath query supplied for `--query`:
In function sort_by(), invalid type for value: OrderedDict([('A01Name', 'test-eastus-cockpit'), ('A02Group', 'cto-common'), ('A03Location', 'eastus'), ('A04Vnet', 'test-eastus'), ('A05Port', '9090'), ('A06Priority', '211'), ('A07Domain', 'Azure-Mgmt'), ('A08Lockstate', 'locked')]), expected one of: ['string', 'number'], received: "null"
To learn more about --query, please visit: https://docs.microsoft.com/cli/azure/query-azure-cli?view=azure-cli-latest
oup:resourceGroup,A03Location:location,A04Vnet:tags.vnet,A05Port:tags.port,A06Priority:tags.priority,A07Domain:tags.domain,A08Lockstate:tags.lockState},&tags.priority)" -o tabl

Invalid jmespath query supplied for `--query`:
In function sort_by(), invalid type for value: OrderedDict([('A01Name', 'test-eastus-cockpit'), ('A02Group', 'cto-common'), ('A03Location', 'eastus'), ('A04Vnet', 'test-eastus'), ('A05Port', '9090'), ('A06Priority', '211'), ('A07Domain', 'Azure-Mgmt'), ('A08Lockstate', 'locked')]), expected one of: ['string', 'number'], received: "null"
To learn more about --query, please visit: https://docs.microsoft.com/cli/azure/query-azure-cli?view=azure-cli-latest
ame:name,A02Group:resourceGroup,A03Location:location,A04Vnet:tags.vnet,A05Port:tags.port,A06Priority:tags.priority,A07Domain:tags.domain,A08Lockstate:tags.lockState}" -o table

Invalid jmespath query supplied for `--query`:
In function sort_by(), invalid type for value: OrderedDict([('A01Name', 'test-eastus-cockpit'), ('A02Group', 'cto-common'), ('A03Location', 'eastus'), ('A04Vnet', 'test-eastus'), ('A05Port', '9090'), ('A06Priority', '211'), ('A07Domain', 'Azure-Mgmt'), ('A08Lockstate', 'locked')]), expected one of: ['string', 'number'], received: "null"
To learn more about --query, please visit: https://docs.microsoft.com/cli/azure/query-azure-cli?view=azure-cli-latest
az network asg list --query "[?tags.vnet == 'test-eastus'].{A01Name:name,A02Group:resourceGroup,A03Location:location,A04Vnet:tags.vnet,A05Port:tags.port,A06Priority:tags.priori

Invalid jmespath query supplied for `--query`:
In function sort_by(), invalid type for value: OrderedDict([('A01Name', 'test-eastus-cockpit'), ('A02Group', 'cto-common'), ('A03Location', 'eastus'), ('A04Vnet', 'test-eastus'), ('A05Port', '9090'), ('A06Priority', '211'), ('A07Domain', 'Azure-Mgmt'), ('A08Lockstate', 'locked')]), expected one of: ['string', 'number'], received: "null"
To learn more about --query, please visit: https://docs.microsoft.com/cli/azure/query-azure-cli?view=azure-cli-latest
az>> exit

Invalid jmespath query supplied for `--query`:
In function sort_by(), invalid type for value: None, expected one of: ['array'], received: "null"
To learn more about --query, please visit: https://docs.microsoft.com/cli/azure/query-azure-cli?view=azure-cli-latest

## To Reproduce:
Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.
I believe the issue is caused by using an incorrect sort key value with sort_by

- _Put any pre-requisite steps here..._
- ``

## Expected Behavior
Every command's --query behavior has no carry-over to future commands

## Environment Summary
```
Windows-10-10.0.17134-SP0
Python 3.6.6
Installer: MSI

azure-cli 2.5.1 *

Extensions:
aks-preview 0.4.5
image-copy-extension 0.0.8
interactive 0.4.4

```
## Additional Context

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.