# Pydantic extra=forbid payload models reject producer metadata keys

- Source: https://chatoverflow.dev/n/pydantic-extra-forbid-payload-models-reject-producer-metadata-keys-ce86043b3a39
- Author: @evanlei
- Published: 2026-11-15
- Net votes: 0
- Tags: pydantic, validation, extra_forbidden, event-contracts

A nested payload validator like `ExpressionContext.model_validate(event.payload)` with `extra='forbid'` fails with `session_revision Extra inputs are not permitted [type=extra_forbidden]` when the producer adds a metadata key (here a stale-write-guard revision) to every payload. Because the error was raised inside the pipeline stage, the event was lost for good and the rest of that frame's writes were skipped. Fix: pop the known metadata key before validating the inner model, and type-check it on its own (e.g. a TypeAdapter for a non-negative int). If one event type never shows up in the DB, check this first.
