fix: 修复 Code Review 发现的 4 个 High + 1 个 Medium 问题
High-1/2: baseline mode 违反 DB CHECK 约束
- ck_mode_enum 扩展为 ('single','multi','baseline')
- baseline 的 run_type 从 'baseline' 改为 'live'(符合现有约束)
- 新增迁移 0017_mode_baseline
High-3: 限流日志 NameError: ip 未定义
- deps.py:190 的 logger.warning 中 ip → client_ip
High-4: 生产 Cookie 缺少 Secure 标志
- auth.py 登录时根据 APP_ENV 设置 secure=True(生产)
Medium-5: 降级日志参数类型错误
- orchestrator.py:266 ok_reports(list) → len(ok_reports)(int)
附加: PredictRequest mode 字段加 pattern 校验,与 DB 约束同源
Co-Authored-By: new-provider/LongCat-2.0 <<EMAIL>>
This commit is contained in:
co-authored by
new-provider/LongCat-2.0 <
parent
0a6af0657a
commit
675e176603
@@ -0,0 +1,39 @@
|
||||
"""扩展 ck_mode_enum 约束支持 baseline 模式
|
||||
|
||||
Revision ID: 0017_mode_baseline
|
||||
Revises: 0016_schedules
|
||||
Create Date: 2026-09-21
|
||||
|
||||
Code Review High-1/2 修复:
|
||||
业务支持 mode='baseline'(非 LLM 统计基线),但 DB CHECK 约束只允许
|
||||
('single', 'multi'),导致 baseline 预测写入时 CheckViolation。
|
||||
run_type='baseline' 改为 'live'(代码侧),约束无需扩展。
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '0017_mode_baseline'
|
||||
down_revision: Union[str, None] = '0016_schedules'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.drop_constraint('ck_mode_enum', 'predictions', type_='check')
|
||||
op.create_check_constraint(
|
||||
'ck_mode_enum', 'predictions',
|
||||
"mode IN ('single', 'multi', 'baseline')",
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# 先清理 baseline 数据再恢复旧约束
|
||||
op.execute("DELETE FROM predictions WHERE mode = 'baseline'")
|
||||
op.drop_constraint('ck_mode_enum', 'predictions', type_='check')
|
||||
op.create_check_constraint(
|
||||
'ck_mode_enum', 'predictions',
|
||||
"mode IN ('single', 'multi')",
|
||||
)
|
||||
Reference in New Issue
Block a user