Fix _dto_to_dict for slots=True dataclasses
The defquery conversion routes inter-service results through
_dto_to_dict which checked __dict__ (absent on slots dataclasses),
producing {"value": obj} instead of proper field dicts. This broke
TicketDTO deserialization in the cart app. Check __dataclass_fields__
first and use dataclasses.asdict() for correct serialization.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -225,7 +225,10 @@ def _dto_to_dict(obj: Any) -> dict[str, Any]:
|
||||
keys for any datetime-valued field so sx handlers can build URL paths
|
||||
without parsing date strings.
|
||||
"""
|
||||
if hasattr(obj, "_asdict"):
|
||||
if hasattr(obj, "__dataclass_fields__"):
|
||||
import dataclasses
|
||||
d = dataclasses.asdict(obj)
|
||||
elif hasattr(obj, "_asdict"):
|
||||
d = dict(obj._asdict())
|
||||
elif hasattr(obj, "__dict__"):
|
||||
d = {k: v for k, v in obj.__dict__.items() if not k.startswith("_")}
|
||||
|
||||
Reference in New Issue
Block a user