fix(p0): #1922 from-assets 空 templateId 双斜杠 404 兜底 #1926
Reference in New Issue
Block a user
Delete Branch "fix/p0-from-assets-default-template-fallback-v2"
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?
P0 Bug 修复
关联 Issue: #1922
根因
双 Bug 链:
templateId='',拼出 URL/templates//editor/clips/from-assets(双斜杠)→ FastAPI 404,完全阻断首次生成流程。修复方案(三层后端兜底 + 独立端点)
app/api/routes/_default_template.pyget_or_create_default_template_id():查有效模板 → 无则 CreateTemplateUseCase 创建默认 voice_over 模板 → 创建异常回滚后重查(防并发唯一键冲突)app/api/routes/templates.pyapp/api/routes/clips_standalone.pyPOST /api/v1/clips/from-assets(tags=[Clips]),template_id从 body 传入可选,为空时后端自动兜底,彻底消除双斜杠路径问题app/api/routes/templates_editor/dependencies.pyresolve_draft_plan_id()(支持 auto_create_default=True 空 tid 兜底),原get_draft_plan_idDepends 改为薄封装app/api/routes/templates_editor/__init__.pyresolve_draft_plan_idapp/api/router.pyclips_standalone_routertests/unit/test_default_template_fallback_p0.py前端配套
前端
useStep2Materials需改为调用新端点POST /api/v1/clips/from-assets,templateId作为 body 字段传入(为空不拼路径,后端自动兜底)。验证方式
备注
旧 PR #1921 因分支基于过期 develop(未合入 #1919/#1920/#1924),本次重建分支基于最新 develop 重提。
🚀 预览环境已部署
🗑️ 预览环境已清理
PR #1926 已关闭或合并,对应的预览环境已被清理。