From a75538873471de5573628f043632f10e26c94507 Mon Sep 17 00:00:00 2001 From: clh02467605 Date: Thu, 10 Sep 2026 18:01:26 +0800 Subject: [PATCH] fix(video): expose task failure code/message in task get and download --- packages/commands/src/commands/video/download.ts | 9 +++++++-- packages/commands/src/commands/video/task-get.ts | 10 ++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/commands/src/commands/video/download.ts b/packages/commands/src/commands/video/download.ts index cbb6e92cc..099cf847a 100644 --- a/packages/commands/src/commands/video/download.ts +++ b/packages/commands/src/commands/video/download.ts @@ -53,10 +53,15 @@ export default defineCommand({ }); if (taskInfo.output.task_status !== "SUCCEEDED") { + const status = taskInfo.output.task_status; + const detail = taskInfo.output.message || taskInfo.output.code; + const message = detail + ? `Task is not complete (status: ${status}): ${detail}` + : `Task is not complete (status: ${status}).`; throw new BailianError( - `Task is not complete (status: ${taskInfo.output.task_status}).`, + message, ExitCode.GENERAL, - "Wait for the task to complete before downloading.", + status === "FAILED" ? undefined : "Wait for the task to complete before downloading.", ); } diff --git a/packages/commands/src/commands/video/task-get.ts b/packages/commands/src/commands/video/task-get.ts index a622f7174..502f60a8d 100644 --- a/packages/commands/src/commands/video/task-get.ts +++ b/packages/commands/src/commands/video/task-get.ts @@ -2,6 +2,7 @@ import { defineCommand, taskPath, detectOutputFormat, + stripUndefined, type DashScopeTaskResponse, } from "bailian-cli-core"; import { emitResult, emitBare } from "bailian-cli-runtime"; @@ -42,15 +43,20 @@ export default defineCommand({ return; } + // 透传服务端失败字段:FAILED 时 output.code / output.message 是排查依据;request_id 便于工单溯源。 emitResult( - { + stripUndefined({ task_id: response.output.task_id, task_status: response.output.task_status, video_url: response.output.video_url, results: response.output.results, submit_time: response.output.submit_time, + scheduled_time: response.output.scheduled_time, end_time: response.output.end_time, - }, + code: response.output.code, + message: response.output.message, + request_id: response.request_id, + }), format, ); },