# RuntimeError: Working outside of application context.

- **ID:** `python/flask-app-context-error`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

在 Flask 应用上下文之外访问了需要上下文的变量，如 current_app 或 g。

## Version Compatibility

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

## Workarounds

1. **** (100% success)
   ```
   with app.app_context():
    # 访问 current_app 等
   ```

## Dead Ends

- **** — 如果 app 未创建或未导入，仍然会出错 (70% fail)
- **** — 没有正确初始化上下文 (80% fail)
