Skip to content

az acr task create failing in az cli 2.72.0 #31440

@adityag221

Description

@adityag221

Describe the bug

We have azure devops pipeline which create ACR tasks, and recently Azure CLI version got updated to 2.72.0 and things are breaking for us now, I checked on my local I was able to create ACR tasks with version 2.71.0 but it's failing with the upgraded version

Related command

az acr task create --name "$taskName"
--resource-group "$acrresourceGroup"
--registry "$acrregistry"
--image "$acrimage"
--platform Linux
--cmd "docker run $acrimage -config $configName -RUNID {{.Run.ID}}"
--assign-identity
--schedule "$schedule"
--context "/dev/null" || { echo "Failed to create ACR task: $taskName"; exit 1; }

Errors

ERROR: Object of type generator is not JSON serializable
Traceback (most recent call last):
File "/opt/az/lib/python3.12/site-packages/knack/cli.py", line 239, in invoke
self.output.out(cmd_result, formatter=formatter, out_file=out_file)
File "/opt/az/lib/python3.12/site-packages/knack/output.py", line 146, in out
output = formatter(obj)
^^^^^^^^^^^^^^
File "/opt/az/lib/python3.12/site-packages/knack/output.py", line 37, in format_json
return json.dumps(input_dict, ensure_ascii=False, indent=2, sort_keys=True, cls=_ComplexEncoder,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.12/json/init.py", line 238, in dumps
**kw).encode(obj)
^^^^^^^^^^^
File "/opt/az/lib/python3.12/json/encoder.py", line 202, in encode
chunks = list(chunks)
^^^^^^^^^^^^
File "/opt/az/lib/python3.12/json/encoder.py", line 432, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "/opt/az/lib/python3.12/json/encoder.py", line 406, in _iterencode_dict
yield from chunks
File "/opt/az/lib/python3.12/json/encoder.py", line 439, in _iterencode
o = _default(o)
^^^^^^^^^^^
File "/opt/az/lib/python3.12/site-packages/knack/output.py", line 30, in default
return json.JSONEncoder.default(self, o)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.12/json/encoder.py", line 180, in default
raise TypeError(f'Object of type {o.class.name} '
TypeError: Object of type generator is not JSON serializable
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
Failed to create ACR task: taskid

Issue script & Debug output

DEBUG: urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
DEBUG: urllib3.connectionpool: https://management.azure.com:443 "PUT /subscriptions//resourceGroups/rg/providers/Microsoft.ContainerRegistry/registries/acr/tasks/?api-version=2019-06-01-preview HTTP/1.1" 200 1611
DEBUG: cli.azure.cli.core.sdk.policies: Response status: 200
DEBUG: cli.azure.cli.core.sdk.policies: Response headers:
DEBUG: cli.azure.cli.core.sdk.policies: 'Cache-Control': 'no-cache'
DEBUG: cli.azure.cli.core.sdk.policies: 'Pragma': 'no-cache'
DEBUG: cli.azure.cli.core.sdk.policies: 'Content-Length': '1611'
DEBUG: cli.azure.cli.core.sdk.policies: 'Content-Type': 'application/json; charset=utf-8'
DEBUG: cli.azure.cli.core.sdk.policies: 'Expires': '-1'
DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-operation-identifier': 'tenantId=tid,objectId=oid'
DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-request-id': 'rid'
DEBUG: cli.azure.cli.core.sdk.policies: 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
DEBUG: cli.azure.cli.core.sdk.policies: 'X-Content-Type-Options': 'nosniff'
DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-writes': '799'
DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-global-writes': '11999'
DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-correlation-request-id': 'cid'
DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-routing-request-id': 'WESTUS:***'
DEBUG: cli.azure.cli.core.sdk.policies: 'X-Cache': 'CONFIG_NOCACHE'
DEBUG: cli.azure.cli.core.sdk.policies: 'X-MSEdge-Ref': 'Ref A: ** Ref B: ** Ref C: 2025-05-09T06:23:42Z'
DEBUG: cli.azure.cli.core.sdk.policies: 'Date': 'Fri, 09 May 2025 06:23:42 GMT'
DEBUG: cli.azure.cli.core.sdk.policies: Response content:
DEBUG: cli.azure.cli.core.sdk.policies: Body is streamable
DEBUG: cli.knack.cli: Event: CommandInvoker.OnTransformResult [<function _resource_group_transform at 0x000001CE6A0ABA60>, <function x509_from_base64_to_hex_transform at 0x000001CE6A0ABB00>]
DEBUG: cli.knack.cli: Event: CommandInvoker.OnFilterResult []
DEBUG: cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 239, in invoke
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/output.py", line 146, in out
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/output.py", line 37, in format_json
File "json_init
.py", line 238, in dumps
File "json\encoder.py", line 202, in encode
File "json\encoder.py", line 432, in _iterencode
File "json\encoder.py", line 406, in _iterencode_dict
File "json\encoder.py", line 439, in _iterencode
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/output.py", line 30, in default
File "json\encoder.py", line 180, in default
TypeError: Object of type generator is not JSON serializable

ERROR: cli.azure.cli.core.azclierror: The command failed with an unexpected error. Here is the traceback:
ERROR: az_command_data_logger: The command failed with an unexpected error. Here is the traceback:
ERROR: cli.azure.cli.core.azclierror: Object of type generator is not JSON serializable
Traceback (most recent call last):
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 239, in invoke
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/output.py", line 146, in out
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/output.py", line 37, in format_json
File "json_init_.py", line 238, in dumps
File "json\encoder.py", line 202, in encode
File "json\encoder.py", line 432, in _iterencode
File "json\encoder.py", line 406, in _iterencode_dict
File "json\encoder.py", line 439, in iterencode
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/output.py", line 30, in default
File "json\encoder.py", line 180, in default
TypeError: Object of type generator is not JSON serializable
ERROR: az_command_data_logger: Object of type generator is not JSON serializable
Traceback (most recent call last):
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 239, in invoke
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/output.py", line 146, in out
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/output.py", line 37, in format_json
File "json_init
.py", line 238, in dumps
File "json\encoder.py", line 202, in encode
File "json\encoder.py", line 432, in _iterencode
File "json\encoder.py", line 406, in _iterencode_dict
File "json\encoder.py", line 439, in _iterencode
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/output.py", line 30, in default
File "json\encoder.py", line 180, in default
TypeError: Object of type generator is not JSON serializable
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues

Expected behavior

ACR tasks created successfully

Environment Summary

azure-cli 2.72.0

core 2.72.0

telemetry 1.1.0

Extensions:

azure-devops 1.0.1

Dependencies:

msal 1.32.3

azure-mgmt-resource 23.1.1

Additional context

It seems while the request was successful with response of 200, yet the Azure CLI was unable to parse the response body.

Metadata

Metadata

Assignees

Labels

Auto-AssignAuto assign by botContainer Registryaz acrService 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

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions