fix(upload): 修复分片上传路由顺序,确保complete/status端点可访问 #188

Merged
xiaoxia merged 1 commits from fix/chunked-upload-route-order into develop 2026-07-09 11:04:04 +08:00
Owner

问题

分片上传路由定义顺序有问题:

  • /{upload_id}/{chunk_index}(动态路径)定义在 /{upload_id}/complete/{upload_id}/status 前面
  • FastAPI 按顺序匹配路由,导致 complete/status 路径的 POST 请求会被 {chunk_index} 当作参数捕获,返回 422 验证错误而非正确路由

修复

调整路由注册顺序:

  1. /init - POST
  2. /{upload_id}/status - GET
  3. /{upload_id}/complete - POST
  4. /{upload_id}/{chunk_index} - POST(动态路径放最后)

验证

  • 所有现有分片上传相关测试通过(32个测试全部通过)
  • 只修改了路由顺序,未改动任何业务逻辑
## 问题 分片上传路由定义顺序有问题: - `/{upload_id}/{chunk_index}`(动态路径)定义在 `/{upload_id}/complete` 和 `/{upload_id}/status` 前面 - FastAPI 按顺序匹配路由,导致 complete/status 路径的 POST 请求会被 `{chunk_index}` 当作参数捕获,返回 422 验证错误而非正确路由 ## 修复 调整路由注册顺序: 1. `/init` - POST 2. `/{upload_id}/status` - GET 3. `/{upload_id}/complete` - POST 4. `/{upload_id}/{chunk_index}` - POST(动态路径放最后) ## 验证 - 所有现有分片上传相关测试通过(32个测试全部通过) - 只修改了路由顺序,未改动任何业务逻辑
xiaoxia added 1 commit 2026-07-09 10:29:43 +08:00
fix(upload): 修复分片上传路由顺序,确保complete/status端点可访问
CI/CD Pipeline / Build & Push Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Build Production Runtime Images (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 / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 2h24m47s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Failing after 2h24m47s
4171dd4420
将动态路由 /{upload_id}/{chunk_index} 移到固定路由 /{upload_id}/status
和 /{upload_id}/complete 之后。FastAPI按顺序匹配路由,之前动态路由
会捕获 complete/status 路径,导致这些端点无法正常访问。
xiaoxia merged commit aaa6e82f1f into develop 2026-07-09 11:04:04 +08:00
Sign in to join this conversation.