Files
xiaoxia-saas/tests/unit/test_empty_plan_id_marks_failed.py
xiaoxia 7fdea8301c
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 45s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 1m50s
CI/CD Pipeline / Validate - Migration (alembic) (push) Successful in 3m8s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 3m15s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 3m23s
CI/CD Pipeline / Validate - Type Check (mypy) (push) Successful in 3m44s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 3m45s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 34s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 33s
CI/CD Pipeline / Build Staging API Image (push) Successful in 5m11s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m51s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 4m4s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 55s
AI Code Review / AI Code Review (pull_request) Failing after 5m51s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 1m17s
CI/CD Pipeline / Staging E2E Tests (push) Successful in 1m30s
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 7m11s
CI/CD Pipeline / Validate - Code Quality (push) Successful in 9m2s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 3m38s
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 9m46s
CI/CD Pipeline / Integration Tests (push) Successful in 3m57s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 4m23s
CI/CD Pipeline / Unit Tests (push) Successful in 14m25s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 12m31s
CI/CD Pipeline / CI Gate (pull_request) Successful in 9s
CI/CD Pipeline / Canary Release to Production (pull_request) Failing after 551h4m13s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 551h4m14s
CI/CD Pipeline / Build Production Worker Image (pull_request) Failing after 551h4m15s
CI/CD Pipeline / Build Production API Image (pull_request) Failing after 551h4m16s
CI/CD Pipeline / Production Browser E2E (push) Failing after 551h4m47s
CI/CD Pipeline / Deploy Production (push) Failing after 551h4m49s
CI/CD Pipeline / Build Production Worker Image (push) Failing after 551h4m50s
CI/CD Pipeline / Build Production API Image (push) Failing after 551h4m51s
CI/CD Pipeline / CI Gate (push) Failing after 551h4m51s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 551h15m3s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 551h15m5s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 551h15m9s
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 551h15m44s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 551h16m37s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Failing after 551h16m55s
CI/CD Pipeline / PR Build Worker Image (push) Failing after 551h18m6s
CI/CD Pipeline / Frontend Lint (push) Failing after 551h19m7s
CI/CD Pipeline / PR Build Web Image (push) Failing after 551h18m8s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 551h19m7s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 551h19m9s
CI/CD Pipeline / Check if frontend-only change (push) Failing after 551h20m3s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 551h19m11s
CI/CD Pipeline / Production Browser E2E (pull_request) Failing after 551h38m6s
CI/CD Pipeline / Build Production Web Image (pull_request) Failing after 551h38m7s
CI/CD Pipeline / Canary Release to Production (push) Failing after 551h38m40s
CI/CD Pipeline / Build Production Web Image (push) Failing after 551h38m42s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 551h48m59s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 551h50m27s
CI/CD Pipeline / PR Build API Image (push) Failing after 551h52m2s
fix: source_edit_plan_id 为空时标记任务为 failed 而非卡在 running (#1481)
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com>
Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
2026-08-24 16:06:00 +08:00

33 lines
1.3 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""回归测试:source_edit_plan_id 为空时任务必须被标记为 failed。
背景 (2026-08-24):确认生成卡在 10%。根因是 worker 在
source_edit_plan_id 为空时直接 return failed,但没有调用 mark_failed
导致 DB 状态永远停在 running。
"""
from pathlib import Path
GENERATION_PY = Path(__file__).resolve().parents[2] / "apps" / "worker" / "worker_app" / "tasks" / "generation.py"
def test_mark_failed_in_else_branch():
"""generation.py 中 source_edit_plan_id 为空的 else 分支必须调用 mark_failed。"""
source = GENERATION_PY.read_text(encoding="utf-8")
# 定位 else 分支:紧跟在 'source_edit_plan_id 为空' 日志之后的 else 块
marker = "source_edit_plan_id 为空"
idx = source.find(marker)
assert idx != -1, f"generation.py 中未找到 '{marker}'"
# 从 marker 位置向后搜索到下一个 return 语句
after_marker = source[idx:]
return_idx = after_marker.find("return {")
assert return_idx != -1, "else 分支中未找到 return 语句"
# 关键断言:marker 和 return 之间必须包含 mark_failed
block = source[idx : idx + return_idx]
assert "mark_failed" in block, (
"else 分支在 return 之前必须调用 _update_task_status(task_id, "
"'mark_failed', ...) 以更新 DB 状态,否则任务永远卡在 running"
)