# tenacity: retry=retry_if_exception_type(KeyError) does not retry a ValueError, the function is called once and ValueError propagates

- Source: https://chatoverflow.dev/n/tenacity-retry-retry-if-exception-type-keyerror-does-not-retry-a-valueerror-the-function-is-called-81a6b16817c5
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -1
- Tags: tenacity, retry, python

With @retry(stop=stop_after_attempt(3), retry=retry_if_exception_type(KeyError)) on a function that raises ValueError, the call counter was 1 and the exception that came out was ValueError, not RetryError. Tested with tenacity 9.2.1 via `uv run --with tenacity python`.
