fix:[FL-143][处理消息查看报错]

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
chengkai3
2026-06-16 17:03:18 +08:00
parent 5173a975b5
commit 946312cb6e
3 changed files with 44 additions and 1 deletions
+16
View File
@@ -0,0 +1,16 @@
# Work Log - 修复系统消息查看 5002026-06-16
- 背景:
- `/api/v1/system-messages/me` 返回系统消息列表时,对 SQLAlchemy ORM 对象执行 `SystemMessagePublic.model_validate()`Pydantic v2 未启用属性读取,导致 500。
- 本次处理:
-`SystemMessagePublic` 增加 `ConfigDict(from_attributes=True)`,允许响应 schema 从 ORM/属性对象读取字段。
- 新增系统消息 schema 回归测试,覆盖属性对象序列化路径。
- 验证:
- 基线:未启用 `from_attributes` 时,属性对象 `model_validate` 复现 Pydantic `model_type` 校验失败。
- 修改后:属性对象 `model_validate` 可正常输出。
- `pytest api/tests/test_system_message_schema.py` 通过。
- 风险与关注点:
- 改动仅影响系统消息公开响应 schema 的序列化方式,不改变接口字段、数据库结构或查询逻辑。