From c0c9765eb0f0fd24497e786f830f4b39e8b8e392 Mon Sep 17 00:00:00 2001 From: saas-backend-agent Date: Wed, 9 Sep 2026 12:53:17 +0800 Subject: [PATCH] =?UTF-8?q?debug:=20lipsync=20=E8=B7=AF=E7=94=B1=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=AF=A6=E7=BB=86=E9=94=99=E8=AF=AF=E6=9A=B4=E9=9C=B2?= =?UTF-8?q?=EF=BC=8C=E5=AE=9A=E4=BD=8D=20staging=20500=20=E6=A0=B9?= =?UTF-8?q?=E5=9B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - _get_service 依赖注入加 try/except,暴露 LipsyncService 初始化错误 - list_lipsync_jobs 加 try/except,暴露 DB 查询错误 - 错误信息包含异常类型和详情,方便 staging 实测定位 --- apps/api/app/api/routes/lipsync.py | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/apps/api/app/api/routes/lipsync.py b/apps/api/app/api/routes/lipsync.py index e7593626e..8ca88f601 100644 --- a/apps/api/app/api/routes/lipsync.py +++ b/apps/api/app/api/routes/lipsync.py @@ -31,7 +31,14 @@ def _get_service( db: Session = Depends(get_db_session), cosyvoice_service: CosyVoiceService = Depends(get_cosyvoice_service), ) -> LipsyncService: - return LipsyncService(db, cosyvoice_service=cosyvoice_service) + try: + return LipsyncService(db, cosyvoice_service=cosyvoice_service) + except Exception as exc: + logger.error("LipsyncService 初始化失败: %s", exc, exc_info=True) + raise HTTPException( + status_code=500, + detail=f"LipsyncService init: {type(exc).__name__}: {exc}", + ) from exc def _resolve_voice_id( @@ -129,13 +136,20 @@ def list_lipsync_jobs( svc: LipsyncService = Depends(_get_service), ): """获取对口型任务列表.""" - items, total = svc.list_jobs( - user_id=current_user.id, - project_id=project_id, - status=status, - offset=offset, - limit=limit, - ) + try: + items, total = svc.list_jobs( + user_id=current_user.id, + project_id=project_id, + status=status, + offset=offset, + limit=limit, + ) + except Exception as exc: + logger.error("list_jobs 查询失败: %s", exc, exc_info=True) + raise HTTPException( + status_code=500, + detail=f"list_jobs error: {type(exc).__name__}: {exc}", + ) from exc return { "items": [LipsyncJobResponse.model_validate(j) for j in items], "total": total,