fix: 修复 voices.py 中 3 处 ruff B904 错误,解除 CI Validate-Style 阻塞 #1667

Merged
xiaoxia merged 1 commits from fix/ruff-b904-voices into develop 2026-09-03 20:35:07 +08:00
Owner

问题

develop 分支上的 Validate - Style CI 检查失败,阻塞了所有新 PR 合并。

根因:PR #1654 引入的 apps/api/app/api/routes/voices.py 中有 3 处 except 块中的 raise 没有使用 from,触发 ruff B904 规则。

修复

except subprocess.TimeoutExpired:
-   raise HTTPException(...)
+   raise HTTPException(...) from None

except Exception as e:
-   raise HTTPException(...)
+   raise HTTPException(...) from e

except IntegrityError:
-   raise HTTPException(...)
+   raise HTTPException(...) from None

影响

  • 修复后 Validate - Style 将通过,解除 PR #1665、#1666 等被阻塞的 PR
  • 仅改 3 行,无功能变更
## 问题 develop 分支上的 `Validate - Style` CI 检查失败,阻塞了所有新 PR 合并。 根因:PR #1654 引入的 `apps/api/app/api/routes/voices.py` 中有 3 处 `except` 块中的 `raise` 没有使用 `from`,触发 ruff B904 规则。 ## 修复 ``` except subprocess.TimeoutExpired: - raise HTTPException(...) + raise HTTPException(...) from None except Exception as e: - raise HTTPException(...) + raise HTTPException(...) from e except IntegrityError: - raise HTTPException(...) + raise HTTPException(...) from None ``` ## 影响 - 修复后 `Validate - Style` 将通过,解除 PR #1665、#1666 等被阻塞的 PR - 仅改 3 行,无功能变更

🚀 预览环境已部署

项目 详情
PR号 #1667
预览链接 https://pr-1667.preview.xiaoxiajianji.com
API环境 staging

💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。

🔄 每次提交新代码后预览环境会自动更新。

🗑️ PR 关闭或合并后,预览环境会自动清理。

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #1667 | | 预览链接 | [https://pr-1667.preview.xiaoxiajianji.com](https://pr-1667.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
xiaoxia added 1 commit 2026-09-03 20:31:00 +08:00
fix: 修复 voices.py 中 3 处 ruff B904 错误(raise without from)
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 2s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 35s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 35s
AI Code Review / AI Code Review (pull_request) Successful in 1m26s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 1m29s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m37s
CI/CD Pipeline / Validate - Style (pull_request) Successful in 1m59s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m27s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 2m47s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m26s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 13s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 4m59s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 1m54s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 29m57s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Successful in 4s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
91dd81073d
xiaoxia force-pushed fix/ruff-b904-voices from f30a678b97 to 91dd81073d 2026-09-03 20:31:00 +08:00 Compare
Collaborator

【阻塞级判定】

  • 是否存在阻塞级问题:否
  • 阻塞级问题数量:0 个

📊 审查概览

  • 整体评价:通过
  • 建议级问题数量:0 个

🔴 阻塞级问题(必须修复)

💡 改进建议(不阻塞合并)

良好实践

  1. 显式异常链处理:在 TimeoutError 和素材库创建失败的异常处理中使用 from None,有效地隐藏了底层实现细节,防止向客户端暴露不必要的堆栈信息,符合安全最佳实践。
  2. 保留调试上下文:在通用异常捕获块 except Exception as e 中使用 from e,显式保留了原始异常链,便于在服务器端日志或调试环境中追踪根本原因。
  3. 日志记录规范:在捕获异常时正确使用了 logger.exception,确保错误堆栈能被正确记录。

🤖 由 AI 代码审查机器人自动生成 | 2026-09-03 12:32:26 | 模型:

### 【阻塞级判定】 - 是否存在阻塞级问题:否 - 阻塞级问题数量:0 个 ### 📊 审查概览 - 整体评价:通过 - 建议级问题数量:0 个 ### 🔴 阻塞级问题(必须修复) 无 ### 💡 改进建议(不阻塞合并) 无 ### ✅ 良好实践 1. **显式异常链处理**:在 `TimeoutError` 和素材库创建失败的异常处理中使用 `from None`,有效地隐藏了底层实现细节,防止向客户端暴露不必要的堆栈信息,符合安全最佳实践。 2. **保留调试上下文**:在通用异常捕获块 `except Exception as e` 中使用 `from e`,显式保留了原始异常链,便于在服务器端日志或调试环境中追踪根本原因。 3. **日志记录规范**:在捕获异常时正确使用了 `logger.exception`,确保错误堆栈能被正确记录。 --- <sub>🤖 由 AI 代码审查机器人自动生成 | 2026-09-03 12:32:26 | 模型: </sub> <!-- AI_CODE_REVIEW_AUTO_COMMENT -->
xiaoxia merged commit c7c30936a9 into develop 2026-09-03 20:35:07 +08:00

🗑️ 预览环境已清理

PR #1667 已关闭或合并,对应的预览环境已被清理。

如有需要,可以重新打开 PR 来重新生成预览环境。

🗑️ **预览环境已清理** PR #1667 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Sign in to join this conversation.