fix: worker 音频 mime 推断补充 .m4a/.mp3/.wav 等 10 种音频后缀 #1537

Merged
xiaoxia merged 3 commits from fix/audio-mime-inference into develop 2026-08-29 12:37:14 +08:00
Owner

问题

infer_mime_type_from_storage_key 只识别视频后缀(.mov/.mp4/.m4v/.avi/.mkv/.webm),其他一律返回 image/jpeg。这导致所有音频文件在 worker ingest 后被标记为 file_type=image,配音上传和克隆音色上传均失败。

修复

apps/worker/worker_app/core/asset_types.pyinfer_mime_type_from_storage_key 中补充音频后缀分支:

后缀 MIME type
.m4a audio/mp4
.mp3 audio/mpeg
.wav audio/wav
.flac audio/flac
.ogg audio/ogg
.aac audio/aac
.wma audio/x-ms-wma
.amr audio/amr
.opus audio/opus
.weba audio/webm

不改 ALLOWED_MIME_TYPES(upload 层已包含所需 audio 类型)。

测试

新增 10 个音频推断单测(含大小写验证),共 13 测试全过。

数据修复 SQL(staging)

先查:

SELECT id, name, file_type, status
FROM assets
WHERE file_type = 'image'
AND (
  name ILIKE '%.m4a' OR name ILIKE '%.mp3' OR name ILIKE '%.wav'
  OR name ILIKE '%.flac' OR name ILIKE '%.ogg' OR name ILIKE '%.aac'
  OR name ILIKE '%.wma' OR name ILIKE '%.amr' OR name ILIKE '%.opus'
  OR name ILIKE '%.weba'
)
ORDER BY created_at DESC;

确认后再改:

UPDATE assets
SET file_type = 'audio', status = 'ready', updated_at = NOW()
WHERE file_type = 'image'
AND (
  name ILIKE '%.m4a' OR name ILIKE '%.mp3' OR name ILIKE '%.wav'
  OR name ILIKE '%.flac' OR name ILIKE '%.ogg' OR name ILIKE '%.aac'
  OR name ILIKE '%.wma' OR name ILIKE '%.amr' OR name ILIKE '%.opus'
  OR name ILIKE '%.weba'
);

注意:修复后 metadata 为空(无 duration),如需完整元数据需重新上传。

## 问题 `infer_mime_type_from_storage_key` 只识别视频后缀(.mov/.mp4/.m4v/.avi/.mkv/.webm),其他一律返回 `image/jpeg`。这导致所有音频文件在 worker ingest 后被标记为 `file_type=image`,配音上传和克隆音色上传均失败。 ## 修复 在 `apps/worker/worker_app/core/asset_types.py` 的 `infer_mime_type_from_storage_key` 中补充音频后缀分支: | 后缀 | MIME type | |------|----------| | .m4a | audio/mp4 | | .mp3 | audio/mpeg | | .wav | audio/wav | | .flac | audio/flac | | .ogg | audio/ogg | | .aac | audio/aac | | .wma | audio/x-ms-wma | | .amr | audio/amr | | .opus | audio/opus | | .weba | audio/webm | 不改 ALLOWED_MIME_TYPES(upload 层已包含所需 audio 类型)。 ## 测试 新增 10 个音频推断单测(含大小写验证),共 13 测试全过。 ## 数据修复 SQL(staging) 先查: ```sql SELECT id, name, file_type, status FROM assets WHERE file_type = 'image' AND ( name ILIKE '%.m4a' OR name ILIKE '%.mp3' OR name ILIKE '%.wav' OR name ILIKE '%.flac' OR name ILIKE '%.ogg' OR name ILIKE '%.aac' OR name ILIKE '%.wma' OR name ILIKE '%.amr' OR name ILIKE '%.opus' OR name ILIKE '%.weba' ) ORDER BY created_at DESC; ``` 确认后再改: ```sql UPDATE assets SET file_type = 'audio', status = 'ready', updated_at = NOW() WHERE file_type = 'image' AND ( name ILIKE '%.m4a' OR name ILIKE '%.mp3' OR name ILIKE '%.wav' OR name ILIKE '%.flac' OR name ILIKE '%.ogg' OR name ILIKE '%.aac' OR name ILIKE '%.wma' OR name ILIKE '%.amr' OR name ILIKE '%.opus' OR name ILIKE '%.weba' ); ``` 注意:修复后 metadata 为空(无 duration),如需完整元数据需重新上传。
xiaoxia added 1 commit 2026-08-29 12:01:14 +08:00
fix: worker 音频 mime 推断补充 .m4a/.mp3/.wav/.flac/.ogg/.aac/.wma/.amr/.opus/.weba
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build 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 API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2m33s
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
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 Worker Image (pull_request) Successful in 1m40s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 1m43s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 3m17s
Preview Deploy / Deploy Preview Environment (pull_request) Failing after 14m11s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Failing after 14m12s
PR Automation / Auto Approve on CI Green (pull_request) Failing after 14m13s
AI Code Review / AI Code Review (pull_request) Failing after 14m13s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Failing after 14m15s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Failing after 14m15s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 14m15s
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 / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Successful in 2m17s
CI/CD Pipeline / CI Gate (pull_request) Failing after 24s
250702de59
infer_mime_type_from_storage_key 此前只识别视频后缀,其他一律返回
image/jpeg,导致所有音频文件在 ingest 后被标记为 file_type=image,
配音上传和克隆音色上传均失败。

补充音频后缀分支,返回对应 audio/... mime type。
新增 10 个音频单测,共 13 测试全过。
xiaoxia added 1 commit 2026-08-29 12:20:19 +08:00
ci: trigger re-run
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2m35s
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 / Validate - Migration (alembic) (pull_request) Successful in 2m47s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 3m46s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 4m10s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 1m47s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 1m50s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 4m32s
CI/CD Pipeline / Validate - Code Quality (pull_request) Has been cancelled
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
AI Code Review / AI Code Review (pull_request) Has been cancelled
PR Automation / Auto Approve on CI Green (pull_request) Has been cancelled
81bc72f86a

🚀 预览环境已部署

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

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

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

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

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #1537 | | 预览链接 | [https://pr-1537.preview.xiaoxiajianji.com](https://pr-1537.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
auto-approve-bot added 1 commit 2026-08-29 12:25:33 +08:00
style: auto-format with black + isort + prettier [skip ci-format-check]
CI/CD Pipeline / Build Staging API 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 / 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 / Validate - Migration (alembic) (pull_request) Successful in 2m38s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 3m4s
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 / Validate - Type Check (mypy) (pull_request) Successful in 3m50s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 3m49s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 4m9s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 1m13s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 1m18s
AI Code Review / AI Code Review (pull_request) Successful in 4m43s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 5m29s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 3m2s
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 7m28s
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 / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Successful in 2m33s
CI/CD Pipeline / CI Gate (pull_request) Successful in 29s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 3m50s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 4m33s
874893900d
Collaborator

【阻塞级判定】

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

📊 审查概览

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

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

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

良好实践

  1. [apps/worker/worker_app/core/asset_types.py] 新增逻辑覆盖了主流音频格式(m4a, mp3, wav, flac, ogg, aac, wma, amr, opus, weba),MIME 类型映射准确。
  2. [tests/unit/test_worker_ingest.py] 为新增功能编写了完整的单元测试,并包含了对大小写不敏感的验证,测试覆盖率高。
  3. [apps/worker/worker_app/core/asset_types.py] 代码结构清晰,通过注释将视频、音频和默认回退逻辑分组,提升了可读性和可维护性。

🤖 由 AI 代码审查机器人自动生成 | 2026-08-29 04:30:16 | 模型:

### 【阻塞级判定】 - 是否存在阻塞级问题:否 - 阻塞级问题数量:0 个 ### 📊 审查概览 - 整体评价:通过 - 建议级问题数量:0 个 ### 🔴 阻塞级问题(必须修复) 无 ### 💡 改进建议(不阻塞合并) 无 ### ✅ 良好实践 1. **[apps/worker/worker_app/core/asset_types.py]** 新增逻辑覆盖了主流音频格式(m4a, mp3, wav, flac, ogg, aac, wma, amr, opus, weba),MIME 类型映射准确。 2. **[tests/unit/test_worker_ingest.py]** 为新增功能编写了完整的单元测试,并包含了对大小写不敏感的验证,测试覆盖率高。 3. **[apps/worker/worker_app/core/asset_types.py]** 代码结构清晰,通过注释将视频、音频和默认回退逻辑分组,提升了可读性和可维护性。 --- <sub>🤖 由 AI 代码审查机器人自动生成 | 2026-08-29 04:30:16 | 模型: </sub> <!-- AI_CODE_REVIEW_AUTO_COMMENT -->
auto-approve-bot approved these changes 2026-08-29 12:35:31 +08:00
auto-approve-bot left a comment
Collaborator

CI全绿,自动审批通过。

CI全绿,自动审批通过。
auto-approve-bot approved these changes 2026-08-29 12:35:31 +08:00
auto-approve-bot left a comment
Collaborator

CI全绿,自动审批通过。

CI全绿,自动审批通过。
xiaoxia merged commit f4754045c1 into develop 2026-08-29 12:37:14 +08:00

🗑️ 预览环境已清理

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

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

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