# KeyError: 'SECRET_KEY'

- **ID:** `python/flask-config-keyerror`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Accessing a configuration key that is not set in the Flask app config.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 2.x | active | — | — |
| 3.x | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY')
   ```
2. **** (90% success)
   ```
   class Config:
    SECRET_KEY = '...'
app.config.from_object(Config)
   ```

## Dead Ends

- **** — Uses insecure default; doesn't solve missing config. (70% fail)
- **** — Insecure for production. (80% fail)
