{
  "id": "python/pytest-httpx-mock-not-matched",
  "signature": "httpx.ConnectError: All connection attempts failed\nDuring handling of the above exception, another exception occurred:\nhttpx.HTTPStatusError: Client error '404 Not Found' for url 'https://api.example.com/v1/users'",
  "signature_zh": "httpx.ConnectError: 所有连接尝试均失败\n在处理上述异常时，又发生了一个异常:\nhttpx.HTTPStatusError: 客户端错误 '404 Not Found'，URL 为 'https://api.example.com/v1/users'",
  "regex": "httpx\\.ConnectError:\\ All\\ connection\\ attempts\\ failed\\\nDuring\\ handling\\ of\\ the\\ above\\ exception,\\ another\\ exception\\ occurred:\\\nhttpx\\.HTTPStatusError:\\ Client\\ error\\ '404\\ Not\\ Found'\\ for\\ url\\ 'https://api\\.example\\.com/v1/users'",
  "domain": "python",
  "category": "network_error",
  "subcategory": null,
  "root_cause": "respx/httpx mock was registered with a URL pattern that does not match the actual request (trailing slash, query string, or http vs https), so the request falls through to the real network.",
  "root_cause_type": "generic",
  "root_cause_zh": "respx/httpx mock 注册的 URL 模式与实际请求不匹配（尾部斜杠、查询字符串或 http 与 https），导致请求穿透到真实网络。",
  "versions": [
    {
      "version": "0.21.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "0.22.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Disabling assertions hides the mismatch but the request still goes to the real network and fails with ConnectError.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The failure is not a timeout; the URL never matches a registered route so no mock intercepts it.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.93,
      "how": "import respx, httpx\n\n@respx.mock\nasync def test_users():\n    respx.get(url__regex=r'/v1/users.*').mock(\n        return_value=httpx.Response(200, json={'id': 1})\n    )\n    async with httpx.AsyncClient(base_url='https://api.example.com') as c:\n        r = await c.get('/v1/users')\n        assert r.status_code == 200",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "respx.get('https://api.example.com/v1/users').mock(...)\n# Enable debug:\nimport logging\nlogging.basicConfig(level=logging.DEBUG)\n# Look for 'No mock matched' in output",
      "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.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-01-15",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}