Simon
|
8bfd0cfdc3
|
fix: v0.5.6 require_role 装饰器 signature + 3 个 schema 同步 migration
🛠️ Bug 修复:
- backend/app/dependencies.py: 修 require_role 装饰器
问题:@wraps 让 FastAPI 看到 __wrapped__ 签名,Depends 默认值未被解析,
current_user 实际是 Depends 对象 → 'Depends' object has no attribute 'roles'
修法:用 inspect 合并签名 + 手动设 wrapper.__signature__,
把 current_user 加进 FastAPI 看到的参数列表
影响:所有用 @require_role 的 endpoint 在生产都受影响,修后正常
📦 Dependencies:
- backend/requirements.txt: pydantic 2.7.4
原因:2.7.5 被 PyPI yank,清华源不缓存,build 失败
(本次不进生产,但合并时一起跟)
🗃️ Alembic migrations(3 个,生产必跑):
- 010_add_agent_otp: agents.otp_secret + agents.otp_enabled
背景:Agent 模型加了 OTP 字段但没建 migration,坐席登录报
'column agents.otp_secret does not exist'
字段:otp_secret VARCHAR(64) NULL, otp_enabled BOOLEAN DEFAULT false
安全:nullable + default,现有坐席不受影响
- 011_add_conversation_impact: conversations 3 个评估字段
背景:坐席发消息 500 报 'column conversations.impact_scope does not exist'
字段:impact_scope INT DEFAULT 0, is_blocking BOOL DEFAULT false,
emotion_state VARCHAR(20) DEFAULT 'normal'
安全:都有 default,现有会话自动填默认值
- 012_sync_remaining_fields: 模型 vs DB 剩余漂移
背景:dev-check-schema-drift 找到 4 个 dev 模式下没暴露的字段
字段:conversations.dify_conversation_id VARCHAR(128) NULL,
employees.it_level VARCHAR(20) DEFAULT 'silver',
employees.it_level_source VARCHAR(20) DEFAULT 'system',
employees.notes JSON DEFAULT '{}'
安全:都有 default,现有数据自动填默认值
部署:
cd /app && python -m alembic upgrade head
docker compose restart backend
验证:curl http://10.90.5.110:8000/health → 200
|
2026-06-16 19:24:27 +08:00 |
|