Skip to content

'az account list-locations -o tsv' has a hidden carriage return in results #31736

@alert101

Description

@alert101

Describe the bug

Some az cli commands return extra carriage returns in the output.

Related command

Getting all regions and looping them with the following code results in errors.

regions=$(az account list-locations --query "[].name" -o tsv)

for region in $regions; do
    # Print out the region, you'll see that the output isn't as it should be
    echo "'$region'"
    # Using the variable in any az cli command will fail in a HTTP 400 Bad Request
    az ml compute list-sizes -g myRg -w myMls -o table -l "$region" --debug
done

Errors

'eastus

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid URL</h2>
<hr><p>HTTP Error 400. The request URL is invalid.</p>
</BODY></HTML>
...

Issue script & Debug output

cli.knack.cli: Command arguments: ['ml', 'compute', 'list-sizes', '-g', 'myRg', '-w', 'myMls', '-o', 'table', '-l', 'eastus\r', '--debug']

Expected behavior

The output shouldn't have extra characters.

Environment Summary

azure-cli 2.74.0

core 2.74.0
telemetry 1.1.0

Extensions:
ml 2.37.1

Dependencies:
msal 1.32.3
azure-mgmt-resource 23.3.0

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

Python (Windows) 3.12.10 (tags/v3.12.10:0cc8128, Apr 8 2025, 11:58:42) [MSC v.1943 32 bit (Intel)]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

This has happened many times before, here are just a few occassions:
#13573
#16695
#28159

Metadata

Metadata

Assignees

Labels

ARMaz resource/group/lock/tag/deployment/policy/managementapp/account management-groupAuto-AssignAuto assign by botMachine Learningaz mlService AttentionThis issue is responsible by Azure service team.bugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions