Azure / Azure/azure-cli-extensions

ComposeElement.__init__() takes from 2 to 3 positional arguments but 4 were given

Open
#6,424 6 comments 2 reactions 0 assignees View on GitHub
Auto-Assign bug ContainerApp customer-reported Service Attention
Dominant language
Python
Stars
454
Forks
1.7k
Avg merge
2d 19h
Merged PRs (30d)
64

Description

### Describe the bug

Fix the implementation problem in the Python modules of the Azure CLI, The error message that was generated :

(ComposeElement.__init__() takes from 2 to 3 positional arguments but 4 were given) refers to a programming problem within the Python modules of the Microsoft Azure CLI.

### Related command

az containerapp compose create\\
--resource-group Test2ResGrp\\
--environment Test2ContEnv\\
--location germanywestcentral\\
--compose-file-path ./rollout_azure.sh.postgres.yml\\
--registry-server testreg\\
--registry-username testuserreg\\
--registry-password id...p1g

### Errors

ERROR: The command failed with an unexpected error. Here is the traceback:
ERROR: ComposeElement.__init__() takes from 2 to 3 positional arguments but 4 were given
Traceback (most recent call last):
File '/usr/lib/python3.10/site-packages/knack/cli.py', line 233, in invoke
cmd_result = self.invocation.execute(args)
File '/usr/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py', line 663, in execute
raise ex
File '/usr/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py', line 726, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
File '/usr/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py', line 697, in _run_job
result = cmd_copy(params)
File '/usr/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py', line 333, in __call__
return self.handler(*args, **kwargs)
File '/usr/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py', line 121, in handler
return op(**command_args)
File '/home/qrod/.azure/cliextensions/containerapp/azext_containerapp/custom.py', line 5301, in create_containerapps_from_compose
parsed_compose_file = ComposeFile(compose_yaml)
File '/home/qrod/.azure/cliextensions/containerapp/pycomposefile/compose_file.py', line 18, in __init__
self.services[service] = Service.from_parsed_yaml(
File '/home/qrod/.azure/cliextensions/containerapp/pycomposefile/compose_element/compose_element.py', line 75, in from_parsed_yaml
return cls(config, compose_path)
File '/home/qrod/.azure/cliextensions/containerapp/pycomposefile/compose_element/compose_element.py', line 42, in __init__
self.set_supported_property_from_config(key, key_config, config_element, compose_path)
File '/home/qrod/.azure/cliextensions/containerapp/pycomposefile/compose_element/compose_element.py', line 56, in set_supported_property_from_config
value = self.transform(value, key, compose_path)
TypeError: ComposeElement.__init__() takes from 2 to 3 positional arguments but 4 were given

### Issue script & Debug output

cli.azure.cli.core.util: Response content:
cli.azure.cli.core.util: {"id":"/subscriptions/XXXXXXXXXXXXXXXx/resourceGroups/ca-session-rg2/providers/Microsoft.App/managedEnvironments/ca-session-env2","name":"ca-session-env2","type":"Microsoft.App/managedEnvironments","location":"East US","systemData":{"createdBy":"XXXXXXXXXXXXXXXx","createdByType":"User","createdAt":"2023-02-13T14:16:30.3861525","lastModifiedBy":"XXXXXXXXXXXXXXXx","lastModifiedByType":"User","lastModifiedAt":"2023-02-16T12:46:01.3234352"},"properties":{"provisioningState":"Succeeded","daprAIInstrumentationKey":null,"daprAIConnectionString":null,"vnetConfiguration":null,"defaultDomain":"wonderfulrock-3e364d43.eastus.azurecontainerapps.io","staticIp":"20.120.126.118","appLogsConfiguration":{"destination":"log-analytics","logAnalyticsConfiguration":{"customerId":"cc2259ab-6cae-46e5-b5a5-44424e39f4c7","sharedKey":null}},"zoneRedundant":false,"kedaConfiguration":{"version":"2.10.0"},"daprConfiguration":{"version":"1.10.7"},"eventStreamEndpoint":"https://eastus.azurecontainerapps.dev/subscriptions/48c2ece5-ded8-4806-8c46-72df34f73606/resourceGroups/ca-session-rg2/managedEnvironments/ca-session-env2/eventstream","customDomainConfiguration":{"customDomainVerificationId":"27451828C7509387ED86B29F850BE20669623FF7DEB55ADFA492D70ACE112A84","dnsSuffix":null,"certificateValue":null,"certificatePassword":null,"thumbprint":null,"subjectName":null,"expirationDate":null},"workloadProfiles":null,"firstPartyConfiguration":null,"infrastructureResourceGroup":null,"peerAuthentication":{"mtls":{"enabled":false}}}}
cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "C:\Users\bayanallouzi\.azure\cliextensions\containerapp\azext_containerapp\custom.py", line 152, in load_yaml_file
return yaml.safe_load(stream.read().replace('\x00', ''))
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\yaml/__init__.py", line 125, in safe_load
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\yaml/__init__.py", line 81, in load
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\yaml/constructor.py", line 49, in get_single_data
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\yaml/composer.py", line 36, in get_single_node
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\yaml/composer.py", line 55, in compose_document
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\yaml/composer.py", line 84, in compose_node File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\yaml/composer.py", line 133, in compose_mapping_node
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\yaml/composer.py", line 84, in compose_node File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\yaml/composer.py", line 133, in compose_mapping_node
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\yaml/composer.py", line 84, in compose_node File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\yaml/composer.py", line 127, in compose_mapping_node
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\yaml/parser.py", line 98, in check_event
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\yaml/parser.py", line 438, in parse_block_mapping_key
yaml.parser.ParserError: while parsing a block mapping
in "", line 7, column 5:
container_name: postgres # Wi ...
^
expected , but found ''
in "", line 33, column 6:
volumes:
^

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 663, in execute
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 697, in _run_job
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 333, in __call__
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
File "C:\Users\bayanallouzi\.azure\cliextensions\containerapp\azext_containerapp\custom.py", line 5504, in create_containerapps_from_compose
compose_yaml = load_yaml_file(compose_file_path)
File "C:\Users\bayanallouzi\.azure\cliextensions\containerapp\azext_containerapp\custom.py", line 158, in load_yaml_file
raise ValidationError('Error parsing {} ({})'.format(file_name, str(ex))) from ex
azure.cli.core.azclierror.ValidationError: Error parsing ./rollout_azure.sh.postgres.yml (while parsing a block mapping
in "", line 7, column 5:
container_name: postgres # Wi ...
^
expected , but found ''
in "", line 33, column 6:
volumes:
^)

cli.azure.cli.core.azclierror: Error parsing ./rollout_azure.sh.postgres.yml (while parsing a block mapping
in "", line 7, column 5:
container_name: postgres # Wi ...
^
expected , but found ''
in "", line 33, column 6:
volumes:
^)
az_command_data_logger: Error parsing ./rollout_azure.sh.postgres.yml (while parsing a block mapping
in "", line 7, column 5:
container_name: postgres # Wi ...
^
expected , but found ''
in "", line 33, column 6:
volumes:
^)
cli.knack.cli: Event: Cli.PostExecute []
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 4.115 seconds (init: 0.682, invoke: 3.432)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.client: Accumulated 0 events. Flush the clients.
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 3886 in cache
telemetry.check: Returns Positive.
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\cli\telemetry\__init__.pyc C:\Users\bayanallouzi\.azure"
telemetry.process: Return from creating process
telemetry.main: Finish creating telemetry upload process.

### Expected behavior

running the script, it should work currently, the execution of the statement fails due to the errors within the python modules!

### Environment Summary

az --version:

azure-cli 2.49.0

core 2.49.0
telemetry 1.0.8

Extensions:
containerapp 0.3.32

Dependencies:
msal 1.20.0
azure-mgmt-resource 22.0.0

Python location '/usr/bin/python3'
Extensions directory '/home/qrod/.azure/cliextensions'

Python (Linux) 3.10.11 (main, Apr 27 2023, 21:52:36) [GCC]

### Additional context

N/A

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.