Conversation
Greptile SummaryThis PR removes the last
Confidence Score: 4/5Safe to merge if The change is intentional and minimal, but silently breaks any event handler that type-hints a packages/reflex-base/src/reflex_base/event/processor/base_state_processor.py — the Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["_transform_event_arg(value, hinted_args)"] --> B{value is dict\nand hinted_args is type?}
B -- No --> G[Other branches: list, Enum, deserializer]
B -- Yes --> C{issubclass\nModel / reflex?}
C -- Yes --> D["hinted_args(**filtered_fields)"]
C -- No --> E{is dataclass?}
E -- Yes --> F["hinted_args(**value)"]
E -- No --> H{pydantic installed?}
H -- No --> G
H -- Yes --> I{issubclass\nBaseModelV2?}
I -- Yes --> J["model_validate(value)"]
I -- No --> K["⚠️ raw dict returned\n(pydantic.v1 models land here)"]
style K fill:#ffcccc,stroke:#cc0000
Reviews (1): Last reviewed commit: "Remove last pydantic.v1 vestiage" | Re-trigger Greptile |
| 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) |
There was a problem hiding this comment.
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.
No description provided.