fix(cover): 修复预览视频存储路径错误导致封面生成 500 #1357
Reference in New Issue
Block a user
Delete Branch "fix/double-slash-oss-path"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
问题
封面生成 API 返回 500,MediaKit 报
DownloadFileError, http status code is 404。根因(两个独立 bug)
Bug 1: 统一渲染引擎 storage_key 路径不匹配(主要问题)
rendered/{plan_id}/{job_id}.mp4edit_plan_generation.py硬编码存储rendered/{plan_id}/output.mp4rendered/f86959d8.../output.mp4→ 404,rendered/gen_f86959d8.../d54bcb32....mp4→ 200Bug 2: Worker _upload_and_record 双斜杠路径
project_id为空时(模板编辑器草稿),f"generated/projects/{project_id}/tasks/..."产生projects//tasks///为/)→ 404修复
edit_plan_generation.pyoutput_url提取实际 storage_key,不再硬编码output.mp4worker/generation.py_upload_and_record过滤空路径段,新文件不再产生//注意
旧数据中已存在的
rendered_storage_key(指向output.mp4)和generated_videos.file_url(含//)需要用户重新生成预览才能修复。新任务不再产生这些问题。根因:模板编辑器草稿不属于任何项目(project_id=''),Worker 构建 storage_key 时 f'generated/projects/{project_id}/tasks/...' 产生 projects//tasks/ 双斜杠路径。文件实际上传到 OSS(URL 返回 200), 但 MediaKit 的 HTTP 客户端规范化 URL(合并 // 为 /),导致 404。 修复(4 层防御): 1. Worker: _upload_and_record 过滤空路径段,新文件不再产生 // 2. cover.py: 获取 URL 后规范化,处理历史脏数据 3. generation.py: _get_task_output_url 规范化复用产物 URL 4. ai_service.py: _call_ai_cover_service 入口规范化,不依赖调用方 新增单测: test_call_ai_cover_url_double_slash_normalized🚀 预览环境已部署
CI全绿,自动审批通过。
CI全绿,自动审批通过。
🗑️ 预览环境已清理
PR #1357 已关闭或合并,对应的预览环境已被清理。
fix(cover): 修复 OSS 路径双斜杠导致 MediaKit 404to fix(cover): 修复预览视频存储路径错误导致封面生成 500