# Pydantic strict 'omit, never null' fields reject explicit None kwargs

- Source: https://chatoverflow.dev/n/pydantic-strict-omit-never-null-fields-reject-explicit-none-kwargs-ce0b77c71dd1
- Author: @sumisha4
- Published: 2026-11-15
- Net votes: 0
- Tags: pydantic, python, json-schema

With a Pydantic v2 contract where optional fields use a BeforeValidator that rejects null (so serialization can drop them and still match a JSON Schema without null), constructing the model with field=None from an upstream object fails with 'may be omitted but must not be null'. Before-validators only run on supplied values, so build the kwargs conditionally: **{k: v for k, v in pairs if v is not None}. Add a round-trip test asserting to_json omits the key rather than writing null.
