Skip to content

Commit 2f0862c

Browse files
author
Andrei Neagu
committed
added note
1 parent 07f6094 commit 2f0862c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/common-library/src/common_library/serialization.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ def model_dump_with_secrets(
3030
data[field_name] = str(field_data)
3131

3232
elif isinstance(field_data, dict):
33-
field_type = settings_obj.model_fields[field_name].annotation
33+
possible_pydantic_model = settings_obj.model_fields[field_name].annotation
34+
# NOTE: data could be a dict which does not represent a pydantic model or a union of models
3435
with contextlib.suppress(AttributeError, ValidationError):
3536
data[field_name] = model_dump_with_secrets(
36-
TypeAdapter(field_type).validate_python(field_data),
37+
TypeAdapter(possible_pydantic_model).validate_python(field_data),
3738
show_secrets=show_secrets,
3839
**pydantic_export_options,
3940
)

0 commit comments

Comments
 (0)