JMESPath error when getting a boards query result count
- 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.**
## Describe the bug
I'm trying to get the resulting item count out of a query using the JMESPath `query` option. I'm new to the JMESPath syntax, but I'm trying to follow along with [specs](https://jmespath.org/specification.html#functions) and [tutorials](https://jmespath.org/tutorial.html) to use the [`count`](https://jmespath.org/specification.html#current-node) or [`length`](https://jmespath.org/specification.html#length) .
The `count` function described on the JMESPath site doesn't seem to work whenever I use it, but the `length` function seems to be an option. Unfortunately, whenever I try a query that appears to work on the JMESPath tutorial section, it will fail in the `az boards query` as a query command parameter.
So far, the only workaround I can find is to pull the query result and count the number of items client-side, but I'm hoping to avoid all the extra data transmission.
**Command Name**
`az boards query`
**Errors:**
```
InvalidArgumentValueError: argument --query: invalid jmespath_type value: 'length(@'
```
```
InvalidArgumentValueError: argument --query: invalid jmespath_type value: 'length([*]'
```
## To Reproduce:
Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.
- Load PowerShell (via Windows Terminal, if that might affect things)
- `az boards query --id="…" --query="length(@)"`
For a given query ID (omitted as `…` in my examples), trying to get the resulting item count always seems to result in an error output similar to this, where `$>` is short for my full PowerShell command prompt:
```
$> az boards query --id="…" --query="length(@)"
InvalidArgumentValueError: argument --query: invalid jmespath_type value: 'length(@'
To learn more about --query, please visit: 'https://docs.microsoft.com/cli/azure/query-azure-cli?view=azure-cli-latest'
$>echo Failed to load python executable.
Failed to load python executable.
$>exit /b 1
```
I tried each of these options as well. These all failed with the same `InvalidArgumentValueError` right before the closing parenthesis (`)`) despite representing a query that worked successfully on the [JMESPath tutorial page](https://jmespath.org/tutorial.html):
- `az boards query --id="…" --query="length(@)"`
- `az boards query --id="…" --query="length([*])"`
- `az boards query --id="…" --query="length([])"`
- `az boards query --id="…" --query="length([:])"`
## Expected Behavior
If a query exists, it feels like this should return the integer results. A query has 20 results, a length query would get back `20`.
Running these `length` queries against the JMESPath tutorial page works fine, so the [query docs](https://docs.microsoft.com/en-us/cli/azure/query-azure-cli?view=azure-cli-latest) make it seem like they should work here as well. Additionally, those same [query docs mention querying for singular values](https://docs.microsoft.com/en-us/cli/azure/query-azure-cli?view=azure-cli-latest#get-a-single-value).
## Environment Summary
```
Windows-10-10.0.19041-SP0
Python 3.6.8
PowerShell 7.1.0
Installer: MSI
azure-cli 2.15.1 *
Extensions:
azure-devops 0.18.0
```
## Additional Context
Contributor guide
Assessment
This issue has not been assessed yet.