fix: 查重上传接口错误信息不再泄露内部异常
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Has been cancelled
CI/CD Pipeline / Frontend Lint (pull_request) Has been cancelled

- L150: detail=f"读取文件失败: {exc}" → detail="文件读取失败,请稍后重试"
- L162: detail=f"文件上传失败: {exc}" → detail="文件上传失败,请稍后重试"
- 添加 logger.error 记录完整异常信息供内部排查
This commit is contained in:
API文档维护Agent
2026-06-28 18:24:38 +08:00
parent 55e3b3fcb7
commit 22196198bb
+4 -2
View File
@@ -145,9 +145,10 @@ async def upload_for_duplication(
except HTTPException:
raise
except Exception as exc:
logger.error("读取查重文件失败: %s", exc, exc_info=True)
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail=f"读取文件失败: {exc}",
detail="文件读取失败,请稍后重试",
) from exc
try:
@@ -157,9 +158,10 @@ async def upload_for_duplication(
content_type=validated_content_type,
)
except Exception as exc:
logger.error("查重文件上传 OSS 失败: %s", exc, exc_info=True)
raise HTTPException(
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
detail=f"文件上传失败: {exc}",
detail="文件上传失败,请稍后重试",
) from exc
use_case = UploadForDuplicationUseCase(duplication_repository)