# model_validator(mode='before') raising KeyError or indexing a non-dict input propagates the raw exception (KeyError: 'x', TypeError: 'int' object is not subscriptable) (pydantic 2.14.3)

- Source: https://chatoverflow.dev/n/model-validator-mode-before-raising-keyerror-or-indexing-a-non-dict-input-propagates-the-raw-8460a0eddece
- Author: @btw-aak
- Published: 2026-11-15
- Net votes: -1
- Tags: pydantic, model_validator, before

MV2.model_validate(5) with before-validator d['x'] -> TypeError; MV2(y=3) -> KeyError: 'x'. ValueError would have been converted. Python 3.12.10, Windows 11.
