fix-data-quality-check
main
「数据管线」页点「运行质量检查」100% 失败;日志页无任何相关记录。
MatchStats
match_id
id
POST /admin/data-quality/run
MatchStats.id.is_(None)
AttributeError
uvicorn.error
propagate=False
MatchStats.id
MatchStats.match_id
Standing.id
数据质量检查完成: finished_without_stats=通过(0); league_without_standings=...
setup_logging
uvicorn
新增 tests/test_data_quality_run.py(3 例,mock session):
tests/test_data_quality_run.py
生产实测: POST /admin/data-quality/run 100% 失败,且日志无任何记录。 根因链: 1. P0-02 把 MatchStats 主键改为 match_id(无 id 属性),但质量检查 查询仍写 MatchStats.id.is_(None) → AttributeError → 500 2. handler 无 logger 调用;未捕获异常走 uvicorn.error(默认 propagate=False),不经过 root handler → 内存日志页/文件日志 都看不到 traceback,排障无据可查 修复: - MatchStats.id → MatchStats.match_id(与 P0-02 模型对齐) - 成功路径记 info 日志(检查名=通过/未通过(计数)) - setup_logging 打开 uvicorn/uvicorn.error 的 propagate, 未捕获异常 traceback 进入内存缓冲与滚动文件 - 回归测试 3 例(mock session):修复前红(3 failed),修复后绿; 全量 329 passed 8 skipped 零回归
No dependencies set.
The note is not visible to the blocked user.
症状
「数据管线」页点「运行质量检查」100% 失败;日志页无任何相关记录。
根因链
MatchStats主键改为match_id(模型无id属性),但POST /admin/data-quality/run的检查查询仍写MatchStats.id.is_(None)→AttributeError→ 500。与数据无关,任何环境必现。uvicorn.errorlogger,其默认propagate=False,不经过 root 的内存缓冲/文件日志 handler修复
MatchStats.id→MatchStats.match_id(检查 2 的Standing.id存在,无需改)数据质量检查完成: finished_without_stats=通过(0); league_without_standings=...setup_logging打开uvicorn/uvicorn.error的 propagate —— 此后任何未捕获 500 的 traceback 都会进入 Admin 日志页与滚动文件测试
新增
tests/test_data_quality_run.py(3 例,mock session):