# pydantic.errors.UrlError: 无效的 URL

- **ID:** `python/pydantic-url-parsing-error`
- **领域:** python
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

使用 HttpUrl 或 AnyUrl 类型时，输入字符串不是有效的 URL（例如缺少协议、格式错误）。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 2.x | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   Ensure full URL: 'https://example.com'
   ```
2. **** (85% 成功率)
   ```
   Use AnyUrl with allowed_schemes if needed
   ```

## 无效尝试

- **** — URL must have scheme for HttpUrl. (90% 失败率)
- **** — URLs cannot contain spaces. (80% 失败率)
