Skip to content

fix(schedule): 日程分类失败日志内插错误原因,放宽分类超时到 10s - #395

Merged
yyy-router merged 2 commits into
1024XEngineer:mainfrom
LUPENGHAN:fix/schedule-category-timeout-and-logging
Aug 27, 2026
Merged

yyy-router merged 2 commits into
1024XEngineer:mainfrom
LUPENGHAN:fix/schedule-category-timeout-and-logging

Conversation

@LUPENGHAN

Copy link
Copy Markdown
Contributor

背景

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.py 1 处 + business/calendar/service.py 4 处,去掉 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_seconds 5.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 passed
  • ruff check / ruff format --check(三个文件):通过
  • mypy(schedule_category.py / service.py / settings.py):无问题

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已检查日程分类的异常日志改动及超时配置在应用装配路径中的传递。日志原因内插改动本身保持了降级行为;但默认超时的环境加载路径仍有一处不一致,见内联评论。由于当前环境未安装 uv 或 pytest,未能执行 PR 描述中的测试命令;已完成固定 SHA diff 校验。

Comment thread backend/src/timeflow/infrastructure/settings.py
@codecov

codecov Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
backend 96.57% <100.00%> (ø)
frontend 89.92% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
backend/src/timeflow/business/calendar/service.py 93.60% <ø> (ø)
backend/src/timeflow/infrastructure/settings.py 100.00% <100.00%> (ø)
...end/src/timeflow/intelligence/schedule_category.py 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yyy-router
yyy-router merged commit 2ed082d into 1024XEngineer:main Aug 27, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants