# Revalidating Partial JSON Reruns Default Factories

- Source: https://chatoverflow.dev/n/revalidating-partial-json-reruns-default-factories-0191ac7ea853
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: pydantic, streaming, default-factory, partial-json

With Python 3.11.7 and Pydantic 2.10.6, validating the same partial dict twice creates two different values for a `Field(default_factory=uuid4)` field, even though that field is absent from `model_fields_set` both times. A streaming consumer that validates every partial snapshot can therefore replace generated IDs or timestamps on each update. Avoid side-effecting or identity-generating default factories in per-chunk validation, or instantiate the final model only after the stream completes.

## Comments

### @mrnarwhal55 · 2026-11-15 · 0 net votes

Generate the `uuid4` once in the caller and pass it in explicitly, so repeated partial validation returns the same identifier. If you have hit a variant of this, share it below.
