containerapp update with yaml file results in exception
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 64
Description
### Describe the bug
I am trying to use the yaml file to update container app with proper probes. But it failed in both 2.77 and 2.78 with the following error:
The command failed with an unexpected error. Here is the traceback:
'datetime.date' object has no attribute '__dict__'
### Related command
az containerapp update --yaml ./xxx.yaml --name xxx --resource-group yyy
### Errors
'datetime.date' object has no attribute '__dict__'
Traceback (most recent call last):
File "/opt/homebrew/Cellar/azure-cli/2.78.0/libexec/lib/python3.13/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/homebrew/Cellar/azure-cli/2.78.0/libexec/lib/python3.13/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
raise ex
File "/opt/homebrew/Cellar/azure-cli/2.78.0/libexec/lib/python3.13/site-packages/azure/cli/core/commands/__init__.py", line 734, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.78.0/libexec/lib/python3.13/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_job
return cmd_copy.exception_handler(ex)
~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
File "/opt/homebrew/Cellar/azure-cli/2.78.0/libexec/lib/python3.13/site-packages/azure/cli/command_modules/containerapp/_client_factory.py", line 28, in _polish_bad_errors
raise ex
File "/opt/homebrew/Cellar/azure-cli/2.78.0/libexec/lib/python3.13/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
result = cmd_copy(params)
File "/opt/homebrew/Cellar/azure-cli/2.78.0/libexec/lib/python3.13/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
return self.handler(*args, **kwargs)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.78.0/libexec/lib/python3.13/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
return op(**command_args)
File "/opt/homebrew/Cellar/azure-cli/2.78.0/libexec/lib/python3.13/site-packages/azure/cli/command_modules/containerapp/custom.py", line 749, in update_containerapp
return update_containerapp_logic(cmd=cmd,
name=name,
...<23 lines>...
no_wait=no_wait,
secret_volume_mount=secret_volume_mount)
File "/opt/homebrew/Cellar/azure-cli/2.78.0/libexec/lib/python3.13/site-packages/azure/cli/command_modules/containerapp/custom.py", line 368, in update_containerapp_logic
return update_containerapp_yaml(cmd=cmd, name=name, resource_group_name=resource_group_name, file_name=yaml, no_wait=no_wait, from_revision=from_revision)
File "/opt/homebrew/Cellar/azure-cli/2.78.0/libexec/lib/python3.13/site-packages/azure/cli/command_modules/containerapp/custom.py", line 209, in update_containerapp_yaml
containerapp_def = _convert_object_from_snake_to_camel_case(_object_to_dict(containerapp_def))
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.78.0/libexec/lib/python3.13/site-packages/azure/cli/command_modules/containerapp/_utils.py", line 913, in _object_to_dict
return json.loads(json.dumps(obj, default=default_handler))
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.13/3.13.8/Frameworks/Python.framework/Versions/3.13/lib/python3.13/json/__init__.py", line 238, in dumps
**kw).encode(obj)
~~~~~~^^^^^
File "/opt/homebrew/Cellar/python@3.13/3.13.8/Frameworks/Python.framework/Versions/3.13/lib/python3.13/json/encoder.py", line 200, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/opt/homebrew/Cellar/python@3.13/3.13.8/Frameworks/Python.framework/Versions/3.13/lib/python3.13/json/encoder.py", line 261, in iterencode
return _iterencode(o, 0)
File "/opt/homebrew/Cellar/azure-cli/2.78.0/libexec/lib/python3.13/site-packages/azure/cli/command_modules/containerapp/_utils.py", line 911, in default_handler
return x.__dict__
^^^^^^^^^^
AttributeError: 'datetime.date' object has no attribute '__dict__'. Did you mean: '__dir__'?
### Issue script & Debug output
append --debug results in the same error message as above. But right before it emits the error messages, it has:
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "GET /subscriptions/xxxx/resourceGroups/xxxx/providers/Microsoft.App/containerApps/xxx?api-version=2025-01-01 HTTP/1.1" 200 4714
### Expected behavior
It should apply the new definition to the container app
### Environment Summary
azure-cli: 2.77 and 2.78
### Additional context
_No response_
Contributor guide
Research direction
Start with azure/cli/command_modules/containerapp/_utils.py, especially _object_to_dict, and follow its caller in custom.py:update_containerapp_yaml. Reproduce the issue with the reported az containerapp update --yaml command and inspect how the fetched container app definition is converted; done means the YAML update applies without the datetime.date exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, python
- Domain
- cli, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100