# pydantic_core._pydantic_core.ValidationError: 1 个验证错误，实例已冻结，无法修改字段 name [类型=frozen_instance]

- **ID:** `python/pydantic-immutable-frozen-assignment`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

模型声明了 model_config = ConfigDict(frozen=True)，因此构造后任何属性赋值都会引发 frozen_instance 错误。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   new_user = user.model_copy(update={'name': 'Bob'})
   ```
2. **** (90% 成功率)
   ```
   class User(BaseModel):
    model_config = ConfigDict(frozen=False)  # default
    name: str
   ```

## 无效尝试

- **** — Bypasses Pydantic's checks and produces an inconsistent model that violates __hash__ and equality guarantees. (75% 失败率)
- **** — Corrupts the model's internal fields storage and can raise KeyError or produce an invalid state. (85% 失败率)
