Skip to content

Top-level query functions aren't parsed correctly #32320

@jovinson-ms

Description

@jovinson-ms

Describe the bug

When a command includes a --query flag with a top-level function, the last character of the query isn't evaluated.

Example:

> az group list --query "length([])"
argument --query: invalid jmespath_type value: 'length([]'

If I include at least one extra space (or =) in the query, things work:

> az group list --query "length([]) "
84

Related command

This seems to be a core issue - I've found the same results with three different provider commands.

Errors

> az group list --query "length([])"
argument --query: invalid jmespath_type value: 'length([]'

Issue script & Debug output

The --debug flag doesn't work because of the parsing issue:

> az group list --query "length([])" --debug
--debug was unexpected at this time.

Expected behavior

I expect top-level query functions to work without whitespace padding.

Environment Summary

azure-cli 2.77.0 *

core 2.77.0 *
telemetry 1.1.0

Extensions:
account 0.2.5
application-insights 1.2.2
azure-devops 1.0.2
fzf 1.0.2
healthcareapis 1.0.1
load 1.1.1
providerhub 1.0.0b2
resource-graph 2.1.0

Dependencies:
msal 1.34.0b1
azure-mgmt-resource 23.3.0

Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe'
Config directory 'C:\Users\jovinson.azure'
Extensions directory 'C:\Users\jovinson.azure\cliextensions'

Python (Windows) 3.13.7 (tags/v3.13.7:bcee1c3, Aug 14 2025, 14:15:11) [MSC v.1944 64 bit (AMD64)]

Additional context

No response

Metadata

Metadata

Labels

ARMaz resource/group/lock/tag/deployment/policy/managementapp/account management-groupAuto-AssignAuto assign by botAuto-ResolveAuto resolve by botAzure CLI TeamThe command of the issue is owned by Azure CLI teamPossible-SolutionSimilar-Issueact-identity-squadquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions