Azure / Azure/azure-cli

az interactive cli gets stuck on the same error, after an error with the 'keys()' query function

Open
#27,228 3 comments 0 reactions 2 assignees Assigned to @zhoxing-ms View on GitHub
act-codegen-extensibility-squad Auto-Assign Auto-Resolve Azure CLI Team customer-reported feature-request Interactive
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### Describe the bug

When an error occurs where the [`keys`](https://jmespath.org/proposals/functions.html#keys) function was used within the `--query` string, the cli becomes unusable, throwing the same error, no matter the command.

![image](https://github.com/Azure/azure-cli/assets/5947757/d473a6e0-06ac-48ff-9cd1-ee3ad9d5073c)

### Related command

`az resource list --query [0].NonExistingProperty`
`az resource list --query [0].keys(NonExistingProperty)`
Error occurs here
`az resource list --query [0].NonExistingProperty`
Same error occurs, even though this command worked before
`az resource list`
Same error occurs, even though a `--query` flag is not even provided

### Errors

Invalid jmespath query supplied for `--query`: In function keys(), invalid type for value: None, expected one of: ['object'], received: "null"

### Issue script & Debug output

![image](https://github.com/Azure/azure-cli/assets/5947757/56961a7f-e49e-4866-957a-8cee25e9f057)

### Expected behavior

The cli should be able to execute the third and fourth command without problem, not throwing the same error over and over.

### Environment Summary

```
azure-cli 2.49.0 *

core 2.49.0 *
telemetry 1.0.8 *

Extensions:
interactive 0.5.1

Dependencies:
msal 1.20.0
azure-mgmt-resource 22.0.0

Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\e.steerneman\.azure\cliextensions'

Python (Windows) 3.10.10 (tags/v3.10.10:aad5f6a, Feb 7 2023, 17:05:00) [MSC v.1929 32 bit (Intel)]

Legal docs and information: aka.ms/AzureCliLegal

You have 3 update(s) available. Consider updating your CLI installation with 'az upgrade'
```

### Additional context

_No response_

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.