{
  "id": "python/django-session-key-error",
  "signature": "KeyError at /dashboard/ 'user_id'",
  "signature_zh": "键错误在/dashboard/ 'user_id'",
  "regex": "KeyError\\ at\\ /dashboard/\\ 'user_id'",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "Attempting to access a session key that does not exist.",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试访问不存在的会话键。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Using request.session['user_id'] without checking",
      "why_fails": "Raises KeyError if missing.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Assuming session always has the key",
      "why_fails": "Session may be empty or expired.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use .get() method",
      "success_rate": 0.95,
      "how": "user_id = request.session.get('user_id')",
      "condition": "",
      "sources": []
    },
    {
      "action": "Check key existence",
      "success_rate": 0.9,
      "how": "if 'user_id' in request.session: ...",
      "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-07-25",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}