# pydantic_core._pydantic_core.ValidationError: 1 validation error for Endpoint
url
  URL scheme should be 'http' or 'https' [type=url_scheme, input_value='ftp://example.com', input_type=str]

- **ID:** `python/pydantic-validation-error-url-scheme`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

AnyHttpUrl / HttpUrl types reject non-http(s) schemes. Passing 'ftp://', 'file://', or 'ws://' triggers url_scheme error.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 2.x | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   from pydantic import BaseModel, AnyUrl

class Endpoint(BaseModel):
    url: AnyUrl
   ```
2. **** (88% success)
   ```
   from pydantic import BaseModel, HttpUrl, field_validator

class Endpoint(BaseModel):
    url: HttpUrl

    @field_validator('url', mode='before')
    @classmethod
    def fix_scheme(cls, v):
        return v.replace('ftp://', 'https://') if isinstance(v, str) else v
   ```

## Dead Ends

- **** — Produces invalid URLs like 'http://ftp://example.com' which fail further validation. (90% fail)
- **** — Loses URL validation entirely; invalid URLs slip through and break HTTP clients downstream. (70% fail)
