Backtestspydanticrun-20260929-204949#13460
Unexpected serialization schema with ValidateAs
Error
The harness couldn't finish this ticket.
api-error at solve. No judgment was produced for this ticket. It counts as an error in the run total.
Solve
—
Wall-clock time in the container
Full test suite
Not run
The harness did not reach the test stage
Contamination audit
Unknown
See the audit notes for this run
Patch size
0vs 0 merged
Changed lines, ours vs merged
The issue
View on GitHubInitial Checks
- I confirm that I'm using Pydantic V2
Description
From https://github.com/pydantic/pydantic/discussions/13232:
import pydantic as p
import typing as t
def first_even(nums: list[int]) -> int:
for i in nums:
if i%2 == 0:
return i
raise ValueError("Even not found.")
class Foo(p.BaseModel):
x: t.Annotated[int, p.ValidateAs(list[int], first_even)]
d = Foo(x=[1, 3, 5, 8, 6, 7])
print(d)
# x=8
print(d.model_dump())
# PydanticSerializationUnexpectedValue(Expected `list[int]` - serialized value may not be as expected [field_name='x', input_value=8, input_type=int])
# {'x': 8}
Example Code
Python, Pydantic & OS Version
mainThe two patches
Our patch+0 −0
No patch was produced.Merged fix · PR #+0 −0
No patch was produced.What the agent reported
Failed to authenticate: OAuth session expired and could not be refreshed