diff --git a/src/containerapp/azext_containerapp/_utils.py b/src/containerapp/azext_containerapp/_utils.py index b1b3fa9bf9a..6dc7b1198a3 100644 --- a/src/containerapp/azext_containerapp/_utils.py +++ b/src/containerapp/azext_containerapp/_utils.py @@ -428,8 +428,14 @@ def _add_or_update_tags(containerapp_def, tags): def _object_to_dict(obj): - import json - return json.loads(json.dumps(obj, default=lambda o: o.__dict__)) + import json, datetime + + def default_handler(x): + if isinstance(x, datetime.datetime): + return x.isoformat() + return x.__dict__ + + return json.loads(json.dumps(obj, default=default_handler)) def _to_camel_case(snake_str): @@ -499,10 +505,10 @@ def _remove_dapr_readonly_attributes(daprcomponent_def): def update_nested_dictionary(orig_dict, new_dict): # Recursively update a nested dictionary. If the value is a list, replace the old list with new list - import collections + from collections.abc import Mapping for key, val in new_dict.items(): - if isinstance(val, collections.Mapping): + if isinstance(val, Mapping): tmp = update_nested_dictionary(orig_dict.get(key, {}), val) orig_dict[key] = tmp elif isinstance(val, list):