{
  "id": "python/flask-test-client-context-missing",
  "signature": "RuntimeError: Working outside of request context.",
  "signature_zh": "运行时错误：在请求上下文之外工作。",
  "regex": "RuntimeError:\\ Working\\ outside\\ of\\ request\\ context\\.",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Using flask.request or session outside of a request context, e.g., in test setup or background tasks.",
  "root_cause_type": "generic",
  "root_cause_zh": "在请求上下文之外使用 flask.request 或 session，例如在测试设置或后台任务中。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Must use with app.test_request_context(): to push context.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Request context is tied to thread; async tasks may not have it.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "with app.test_request_context('/'):\n    # use request",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.8,
      "how": "For background tasks, pass request data explicitly instead of using context.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-02-14",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}