Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,7 @@ def _transform_event_arg(value: Any, hinted_args: Any) -> Any:
return hinted_args(**value)
if find_spec("pydantic"):
from pydantic import BaseModel as BaseModelV2
from pydantic.v1 import BaseModel as BaseModelV1

if issubclass(hinted_args, BaseModelV1):
return hinted_args.parse_obj(value)
if issubclass(hinted_args, BaseModelV2):
return hinted_args.model_validate(value)
Comment on lines 116 to 120
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Silent breaking change for pydantic.v1 model arguments

Any event handler that type-hints an argument as a pydantic.v1.BaseModel subclass will now receive a raw dict from the frontend instead of a deserialized model instance. Because pydantic.v1.BaseModel and pydantic.BaseModel (v2) are completely separate class hierarchies, issubclass(hinted_args, BaseModelV2) returns False for v1 compat models — the dict falls through all branches and is passed as-is. Handlers that then access attributes (e.g. model.name) will raise AttributeError at runtime with no helpful error message.

if isinstance(value, list) and (hinted_args is set or hinted_args is frozenset):
Expand Down
Loading