{
  "id": "python/requests-connectionerror-too-many-redirects",
  "signature": "requests.exceptions.TooManyRedirects: Exceeded 30 redirects while fetching 'https://redirect.example.com'",
  "signature_zh": "requests.exceptions.TooManyRedirects: 在获取'https://redirect.example.com'时超过30次重定向",
  "regex": "requests\\.exceptions\\.TooManyRedirects:\\ Exceeded\\ 30\\ redirects\\ while\\ fetching\\ 'https://redirect\\.example\\.com'",
  "domain": "python",
  "category": "network_error",
  "subcategory": null,
  "root_cause": "The server is redirecting the client in a loop or too many times.",
  "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": "Disabling redirects entirely",
      "why_fails": "May miss the final target if redirects are legitimate.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Increasing the maximum redirect limit arbitrarily",
      "why_fails": "If it's a loop, increasing limit does not help; it will still exceed.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Manually handle redirects by inspecting the Location header",
      "success_rate": 0.85,
      "how": "response = requests.get('https://redirect.example.com', allow_redirects=False)\nwhile response.is_redirect:\n    next_url = response.headers['Location']\n    response = requests.get(next_url, allow_redirects=False)\n    if response.status_code == 200:\n        break",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a session with a custom redirect handler to detect loops",
      "success_rate": 0.8,
      "how": "from requests import Session\ns = Session()\ns.max_redirects = 10\nresponse = s.get('https://redirect.example.com')",
      "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": "2025-09-10",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}