Skip to content

fix(types): PostalArea TypeAdapter output is not round-trippable #1086

Description

@bokelley

Version

adcp==8.0.0b9

Reproduction

from adcp.types import PostalArea
from pydantic import TypeAdapter

adapter = TypeAdapter(PostalArea)
value = adapter.validate_python({"system": "us_zip", "values": ["10001"]})
wire = adapter.dump_python(value, mode="json")
print(wire)
adapter.validate_python(wire)

The dump is:

{"country": "US", "system": "us_zip", "values": ["10001"]}

Re-validating that output fails because country US expects native systems zip or zip_plus_four, while the parsed legacy arm retained us_zip.

This also breaks ordinary Pydantic model dump/reconstruct cycles for TargetingOverlay.geo_postal_areas and geo_postal_areas_exclude.

Expected

TypeAdapter(PostalArea) output should validate through the same adapter. Either the legacy fused system should remain countryless on serialization, or it should normalize to the matching native system when adding country.

Context

This surfaced while applying the beta.9 object-union migration from #1084.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions