fix(ecommerce): video 400 error — use OSS URLs instead of data URLs for video generation

The renderScene function was passing local data URLs (data:image/png;base64,...)
as imageUrl and referenceUrls to createVideoTask, which the /api/ai/video endpoint
rejects with 400 Bad Request. The planning phase already uploads images to OSS
but the resulting URLs were not returned to the component.

- Add imageUrls field to EcommerceVideoPlanResult
- Return OSS imageUrls from runVideoPlan alongside existing plan data
- Use planResult.imageUrls[0] in handleRender instead of productImageDataUrls[0]
- Use planResult?.imageUrls[0] for sourceImage display fallback

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-06-02 19:37:29 +08:00
parent e5e5af5b54
commit 5fcd225825
7 changed files with 82 additions and 52 deletions
@@ -170,7 +170,7 @@ export default function EcommerceVideoWorkspace({
const handleRender = async () => {
if (!planResult || !scenes.length) return;
const imageUrl = productImageDataUrls[0] || "";
const imageUrl = planResult.imageUrls[0] || "";
setStage("rendering");
setError(null);
renderAbortRef.current = { current: false };
@@ -213,7 +213,7 @@ export default function EcommerceVideoWorkspace({
const completedScenes = scenes.filter((s) => s.status === "completed" && s.resultUrl);
const primaryVideo = completedScenes[0]?.resultUrl;
const canRender = planResult?.compliance.allow_video_generation && stage === "planned";
const sourceImage = productImageDataUrls[0] || "";
const sourceImage = planResult?.imageUrls[0] || productImageDataUrls[0] || "";
const flowHasStarted = stage !== "idle" || completedSteps.length > 0 || scenes.length > 0;
const flowMeta = `${platform} / ${aspectRatio} / ${durationSeconds}s / ${resolution}`;
const planActionLabel = stage === "planning"
@@ -77,7 +77,7 @@ export async function runVideoPlan(
const compliance = await checkCompliance(summary, selling, storyboard, signal);
onStepDone("compliance");
return { summary, selling, creatives, storyboard, videoPrompts, compliance };
return { imageUrls, summary, selling, creatives, storyboard, videoPrompts, compliance };
}
export interface RenderSceneInput {
@@ -31,6 +31,7 @@ export interface EcommerceVideoSceneTask {
}
export interface EcommerceVideoPlanResult {
imageUrls: string[];
summary: ProductSummary;
selling: SellingPointResult;
creatives: CreativeOption[];