Skip to content

Commit e43cbac

Browse files
committed
fix: prioritize pydantic v2 root attribute check in safely_extract_scalar_value
1 parent 950ec67 commit e43cbac

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

app/bss/types.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,12 @@ def safely_extract_scalar_value(obj: object):
263263
actual value for a scalar"""
264264
if is_scalar(obj):
265265
return obj
266-
if hasattr(obj, "__root__"):
267-
return obj.__root__
268-
elif hasattr(obj, "root"):
266+
if hasattr(obj, "root"):
269267
# pydantic 2.x
270268
return obj.root
269+
elif hasattr(obj, "__root__"):
270+
# pydantic 1.x (legacy fallback)
271+
return obj.__root__
271272

272273
raise ValueError(f"Cannot extract scalar value from {type(obj)} {obj}")
273274

0 commit comments

Comments
 (0)