release: v1.17.12 — 修复 CI 在新版 FastAPI 上路由注册失败

DELETE /api/v1/strategies/{id} 原用 status_code=204,较新 FastAPI/Starlette
在路由注册阶段(add_api_route)就抛 AssertionError: Status code 204 must
not have a response body,导致 CI ubuntu 矩阵 21 个 web 测试因 fixture
导入 router 连带 ERROR。改为返回 200 + {"deleted": id} 确认体。
This commit is contained in:
Justin Gu
2026-07-04 20:50:07 +08:00
parent 05dc9a74af
commit ee628c1b34
4 changed files with 21 additions and 6 deletions
+9 -3
View File
@@ -80,9 +80,15 @@ async def create_saved_strategy(req: SavedStrategyCreate) -> SavedStrategy:
return _to_response(saved)
@router.delete("/strategies/{strategy_id}", status_code=204)
async def delete_saved_strategy(strategy_id: str) -> None:
"""按 id 删除一条已保存策略。不存在则 404"""
@router.delete("/strategies/{strategy_id}")
async def delete_saved_strategy(strategy_id: str) -> dict[str, str]:
"""按 id 删除一条已保存策略。不存在则 400
注:不用 204No Content),因较新 FastAPI 在路由注册阶段就拒绝
status_code=204 且有响应模型的端点("204 must not have a response body"),
返回简单确认体更兼容、前端无需特判。
"""
store = get_store()
if not store.delete(strategy_id):
raise ValueError(f"策略 '{strategy_id}' 不存在")
return {"deleted": strategy_id}