Skip to content

Codex/task4 compatibility boundary - #77

Merged
XiaoCow666 merged 2 commits into
XiaoCow666:mainfrom
BloodHand180621:codex/task4-compatibility-boundary
Oct 9, 2026
Merged

XiaoCow666 merged 2 commits into
XiaoCow666:mainfrom
BloodHand180621:codex/task4-compatibility-boundary

Conversation

@BloodHand180621

Copy link
Copy Markdown
Contributor

本 PR 改进代码提交评估失败时的恢复与可观测性,同时保持旧调用兼容。
变更内容

  • 评估异常时回滚数据库会话,避免事务处于失败状态。
  • 将提交记录明确标记为 failed。
  • 保存具体失败原因到 Submission.feedback。
  • 使用 Flask logger 记录异常及 submission_id。
  • 不改变原有请求字段、成功响应和错误状态码。
    验证
    新增回归测试覆盖:
  • 旧版请求格式 code + assignment_id
  • 评估器异常
  • HTTP 500 响应
  • 提交状态为 failed
  • 失败原因被保存
  • 日志包含提交 ID
    测试结果:
    python -m pytest tests/test_task4_submission_failure_recovery.py -q
    1 passed

@XiaoCow666 XiaoCow666 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

CodeSense 自动评审

未发现会阻塞合并的安全风险、明显回归或核心目标未完成的问题。异常分支会回滚会话、持久化 failed 状态和反馈,并记录包含 submission_id 的异常日志。

合并后可以继续改进的地方

  • 测试在 create_app('testing') 之后才修改 SQLALCHEMY_DATABASE_URI;若应用工厂已初始化 SQLAlchemy 引擎,该修改可能不会生效,测试可能操作默认数据库,建议在创建应用前配置测试数据库或通过应用工厂配置传入。
  • 测试清理阶段执行 db.drop_all(),会增加误删共享测试数据库表的风险;可改为使用独立临时数据库并仅清理该数据库。

已有验证信息

  • PR 提供的检查证据为:python -m pytest tests/test_task4_submission_failure_recovery.py -q,结果为 1 passed。

评审事件:dcd6dfa0-c39c-11f1-918a-e15e226f9ba5

@XiaoCow666
XiaoCow666 merged commit d5f8712 into XiaoCow666:main Oct 9, 2026
1 check 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