fix(schedule): 日程分类失败日志内插错误原因,放宽分类超时到 10s - #395
Merged
yyy-router merged 2 commits intoAug 27, 2026
Merged
yyy-router merged 2 commits into
yyy-router merged 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
yyy-router
approved these changes
Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
main.py的日志格式是format="%(asctime)s %(levelname)s %(name)s: %(message)s",不渲染extra字段。日程分类模块此前把错误原因放在extra={"error_type": ...}里,线上日志只显示干巴巴的 "leaving category null",看不到真正原因(超时 / 供应商错误 / 非法 JSON / 枚举越界等)。realtime/agent.py里已注释记录过同一坑——main.py的日志格式不会渲染 extra,静默丢原因。改动
日志内插错误原因(2 文件 5 处):
intelligence/schedule_category.py1 处 +business/calendar/service.py4 处,去掉extra={"error_type": type(exc).__name__},改为把type(exc).__name__, exc作为位置参数内插进消息文本(error_type=%s): %s。错误日志从schedule category classification failed; leaving category null变成schedule category classification failed (error_type=TimeoutError): exception text; leaving category null。放宽分类超时:
settings.py的schedule_category_timeout_seconds5.0s → 10.0s,减少快速超时导致的 category 为空。刻意不动的两处:
service.py的 "schedule category classifier returned an invalid value" warning(本就没有extra)main.py的 "schedule category classification is not configured" warning(extra用的是needs键,属配置提示,不是错误原因)纯日志输出与配置调整,不改变行为,无新逻辑、无新依赖。
验证
pytest tests/intelligence/test_schedule_category.py tests/test_schedule_application_service.py --no-cov:110 passedruff check/ruff format --check(三个文件):通过mypy(schedule_category.py / service.py / settings.py):无问题