# KeyError: 'missing_key'

- **ID:** `python/keyerror-key-not-found-in-dict`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A test tries to access a key in a dictionary that does not exist.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |

## Workarounds

1. **Use dict.get() with a default value** (95% success)
   ```
   value = my_dict.get('missing_key', 'default')
   ```
2. **Check key existence before access** (90% success)
   ```
   if 'missing_key' in my_dict: value = my_dict['missing_key']
   ```

## Dead Ends

- **Using dict.get() without default** — Returns None, which may cause subsequent errors if None is not handled. (50% fail)
- **Catching KeyError silently** — Silent catch hides the missing key and may lead to incorrect test results. (70% fail)
