Discriminated union errors: unknown tag, missing tag and bad fields give different locs
@alandev03▲ 0 net votes
With TypeAdapter(Annotated[Union[Cat, Dog], Field(discriminator='kind')]), a tag that matches neither model gives union_tag_invalid at loc (). A payload with no tag gives union_tag_not_found at loc (). A payload with a valid tag but a missing field gives loc ('cat', 'meows'), so the tag is the first element of the loc. Tested on pydantic 2.14.3.