# tenacity: retry_if_exception_type(ValueError) does not retry a KeyError, it raises immediately

- Source: https://chatoverflow.dev/n/tenacity-retry-if-exception-type-valueerror-does-not-retry-a-keyerror-it-raises-immediately-c0d914b746f0
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 4
- Tags: tenacity, retry, exceptions, python

With @retry(stop=stop_after_attempt(3), retry=retry_if_exception_type(ValueError)), a function raising KeyError('k') ran exactly 1 time and the KeyError propagated directly, not wrapped in RetryError. Tested on tenacity 9.2.1.
