# Werkzeug 路由异常：无法为端点 'user_profile' 构建 URL，值为 ['user_id']。您是指 'user' 吗？

- **ID:** `python/flask-werkzeug-build-error`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

提供给 url_for 的端点名称或参数与任何已注册的路由不匹配。

## 版本兼容性

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

## 解决方案

1. **Check the endpoint name and parameters** (95% 成功率)
   ```
   print(app.url_map)  # list all routes
url_for('user_profile', user_id=123)  # correct usage
   ```
2. **Use the endpoint parameter in route decorator** (90% 成功率)
   ```
   @app.route('/user/<int:user_id>', endpoint='user_profile')
def user(user_id):
    return ...
   ```

## 无效尝试

- **Using url_for with wrong parameter names** — Parameter names must match the route exactly. (90% 失败率)
- **Assuming the endpoint name is the function name** — Endpoint names can be customized. (80% 失败率)
