azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

JMESPath double-quotes disappear in powershell-core

Open Timo-Weike opened this issue 1 year ago • 3 comments

Describe the bug

When I run

 az group list --query '[?tags."aks-managed-cluster-name"==''somename'']'

then I get the following error

argument --query: invalid jmespath_type value: "[?tags.aks-managed-cluster-name=='somename']"

Notice the missing double quots in the path.

I also tried other variants of the input to get the quotes, but none seam to work.

Related command

 az group list --query '[?tags."aks-managed-cluster-name"==''somename'']'

Errors

argument --query: invalid jmespath_type value: "[?tags.aks-managed-cluster-name=='somename']"

Issue script & Debug output

cli.knack.cli: Command arguments: ['group', 'list', '--query', "[?tags.aks-managed-cluster-name=='somename']", '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x023AB418>, <function OutputProducer.on_global_arguments at 0x0258C730>, <function CLIQuery.on_global_arguments at 0x025AA388>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'group': ['azure.cli.command_modules.resource']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name                  Load Time    Groups  Commands
cli.azure.cli.core: resource                  0.015        47       207
cli.azure.cli.core: Total (1)                 0.015        47       207
cli.azure.cli.core: Loaded 47 groups, 207 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command  : group list
cli.azure.cli.core: Command table: group list
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x04A13E80>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\WEIK014\.azure\commands\2024-10-16.08-57-36.group_list.42908.log'.
az_command_data_logger: command args: group list --query {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x04A3AF58>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x04A43028>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x04A4D4F0>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
urllib3.connectionpool: Starting new HTTPS connection (1): app.aladdin.microsoft.com:443
urllib3.connectionpool: https://app.aladdin.microsoft.com:443 "GET /api/v1.0/suggestions?query=%7B%22command%22%3A+%22group+list%22%2C+%22parameters%22%3A+%22--query%22%7D&clientType=AzureCli&context=%7B%22versionNumber%22%3A+%222.42.0%22%2C+%22errorType%22%3A+%22InvalidJMESPathQuery%22%2C+%22correlationId%22%3A+%22e8d68498-7625-48df-944b-013216e4e755%22%2C+%22subscriptionId%22%3A+%225d751263-acf6-4d8f-881a-944ccf3afd06%22%2C+%22eventId%22%3A+%22db6cbf8d-4f95-4ae5-8f13-0eb62325517f%22%7D HTTP/1.1" 200 None

Expected behavior

That the quotes stay in the input string.

Environment Summary

azure-cli 2.42.0 *

core 2.42.0 * telemetry 1.0.8 *

Dependencies: msal 1.20.0 azure-mgmt-resource 21.1.0b1

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

Python (Windows) 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:37:59) [MSC v.1933 32 bit (Intel)]

Legal docs and information: aka.ms/AzureCliLegal

OS: Windows 11 Shell: PowershellCore

Name                           Value
----                           -----
PSVersion                      7.4.5
PSEdition                      Core
GitCommitId                    7.4.5
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Additional context

when I run

echo '[?tags."aks-managed-cluster-name"==''somename'']'

the quotes do not disappear.

Timo-Weike avatar Oct 16 '24 07:10 Timo-Weike

Hi @Timo-Weike,

2.42.0 is not the latest Azure CLI(2.65.0).

If you haven't already attempted to do so, please upgrade to the latest Azure CLI version by following https://learn.microsoft.com/en-us/cli/azure/update-azure-cli.

Thank you for opening this issue, we will look into it.

yonzhan avatar Oct 16 '24 07:10 yonzhan

Here are some similar issues that might help you. Please check if they can solve your problem.

  • #7124

github-actions[bot] avatar Oct 16 '24 07:10 github-actions[bot]

I just noticed this with my coworkers too.

On macOS this command does work:

 --query 'object."some-key"'

For my coworkers on windows it does not.

They need to add backslashes so that the double quotes do not get removed:

--query 'object.\"some-key\"'

We are both on ps core. The behaviour is little bit frustrating, because like this you can write a ps1 script that works on both platforms. One workaround is to handle the specific os in the script.

@yonzhan @zhoxing-ms

xIceFox avatar Nov 27 '25 11:11 xIceFox