Azure / Azure/azure-cli-extensions

[containerapp] containerapp update with yaml file results in exception

Open
#9,978 2 comments 1 reaction 2 assignees Claimed by @a0x1ab View on GitHub
Auto-Assign ContainerApp Service Attention
Dominant language
Python
Stars
454
Forks
1.7k
Avg merge
2d 19h
Merged PRs (30d)
64

Description

Source: https://github.com/Azure/azure-cli/issues/32323 (by @laorient)
Affected extension: `containerapp` (`src/containerapp/`)

---

<<>>
# Issue #32323 (by @laorient)
## Title
containerapp update with yaml file results in exception

## Body
### 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_

## Comments
### Comment by @yonzhan

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

### Comment by @Greedygre
Hi @laorient

Can you show the repro yaml file?
Or Do you know which property in the yaml file using type `datetime`?

Thanks

### Comment by @laorient
> Hi @laorient
>
> Can you show the repro yaml file?
> Or Do you know which property in the yaml file using type `datetime`?
>
> Thanks

I don't see any datetime property in my yaml. The only thing resemble one is the apiVersion.
<<>>

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.