fix(ingest-jobs): GET /{job_id} 查不到时返回 404 而非 500 #1553
Reference in New Issue
Block a user
Delete Branch "fix/ingest-jobs-404-not-found"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
改动
apps/api/app/api/routes/ingest_jobs.py的 GET/{job_id}:job 不存在时当前raise ValueError(...)被全局异常处理器映射成 500,客户端拿不到合理的「未找到」语义。改为raise HTTPException(status_code=404, detail=...)。测试
新增
tests/unit/test_ingest_jobs_route_404.py:test_get_ingest_job_not_found_returns_404:repo.get 返 None → 404,detail 含 job_idtest_get_ingest_job_found_returns_200:repo.get 返 IngestJob 实体 → 200 + 字段完整全量单测 13907 passed, 16 skipped。
🚀 预览环境已部署
【阻塞级判定】
📊 审查概览
🔴 阻塞级问题(必须修复)
无
💡 改进建议(不阻塞合并)
无
✅ 良好实践
HTTPException替代ValueError,符合 FastAPI 框架规范,确保资源未找到时返回标准的 HTTP 404 状态码,而非 500 内部服务器错误。app.dependency_overrides进行依赖注入的 Mock,这是测试 FastAPI 路由的最佳实践,确保了测试的隔离性和准确性。🤖 由 AI 代码审查机器人自动生成 | 2026-08-30 03:43:27 | 模型:
CI全绿,自动审批通过。
CI全绿,自动审批通过。
🗑️ 预览环境已清理
PR #1553 已关闭或合并,对应的预览环境已被清理。