{
  "id": "python/flask-secret-key-must-be-set",
  "signature": "RuntimeError: The session is unavailable because no secret key was set. Set the secret_key on the application to something unique and secret.",
  "signature_zh": "RuntimeError: 会话不可用，因为未设置密钥。请为应用设置唯一且保密的 secret_key。",
  "regex": "RuntimeError:\\ The\\ session\\ is\\ unavailable\\ because\\ no\\ secret\\ key\\ was\\ set\\.\\ Set\\ the\\ secret_key\\ on\\ the\\ application\\ to\\ something\\ unique\\ and\\ secret\\.",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "app.secret_key is None/empty, but session, flash, or CSRF (Flask-WTF) requires signing.",
  "root_cause_type": "generic",
  "root_cause_zh": "app.secret_key 为 None 或空，但 session、flash 或 CSRF（Flask-WTF）需要签名。",
  "versions": [
    {
      "version": "2.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Committed secret leaks; session forgery risk.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Rotates key each request; sessions invalidate immediately.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "app.config['SECRET_KEY'] = os.environ['FLASK_SECRET_KEY']  # set a 32+ byte random value in env",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Generate once: `python -c 'import secrets; print(secrets.token_hex(32))'` and store in .env / secrets manager.",
      "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.89,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-04-08",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}