{
  "id": "python/pydantic-validation-error-url-scheme",
  "signature": "pydantic_core._pydantic_core.ValidationError: 1 validation error for Endpoint\nurl\n  URL scheme should be 'http' or 'https' [type=url_scheme, input_value='ftp://example.com', input_type=str]",
  "signature_zh": "pydantic_core._pydantic_core.ValidationError: Endpoint 模型验证错误：URL scheme 必须是 'http' 或 'https'",
  "regex": "pydantic_core\\._pydantic_core\\.ValidationError:\\ 1\\ validation\\ error\\ for\\ Endpoint\\\nurl\\\n\\ \\ URL\\ scheme\\ should\\ be\\ 'http'\\ or\\ 'https'\\ \\[type=url_scheme,\\ input_value='ftp://example\\.com',\\ input_type=str\\]",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "AnyHttpUrl / HttpUrl types reject non-http(s) schemes. Passing 'ftp://', 'file://', or 'ws://' triggers url_scheme error.",
  "root_cause_type": "generic",
  "root_cause_zh": "AnyHttpUrl / HttpUrl 类型拒绝非 http(s) 协议。传入 'ftp://'、'file://' 或 'ws://' 会触发 url_scheme 错误。",
  "versions": [
    {
      "version": "2.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Produces invalid URLs like 'http://ftp://example.com' which fail further validation.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Loses URL validation entirely; invalid URLs slip through and break HTTP clients downstream.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "from pydantic import BaseModel, AnyUrl\n\nclass Endpoint(BaseModel):\n    url: AnyUrl",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "from pydantic import BaseModel, HttpUrl, field_validator\n\nclass Endpoint(BaseModel):\n    url: HttpUrl\n\n    @field_validator('url', mode='before')\n    @classmethod\n    def fix_scheme(cls, v):\n        return v.replace('ftp://', 'https://') if isinstance(v, str) else v",
      "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-08-03",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}