# RuntimeError: The session is unavailable because no secret key was set. Set the secret_key on the application to something unique and secret.

- **ID:** `python/flask-secret-key-required`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Flask session (or CSRF) requires app.secret_key but it was never configured, often in tests or a fresh deploy.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   Set a secret key from environment:
app.config['SECRET_KEY'] = os.environ['SECRET_KEY']
   ```
2. **** (85% success)
   ```
   For tests only, generate a fixed key:
app.config['SECRET_KEY'] = 'test-key'
   ```

## Dead Ends

- **** — Permanence affects cookie lifetime, not the required signing key. (90% fail)
- **** — Most session backends still need a secret key for signing. (70% fail)
