Skip to content

利用 AI 大模型和自动化工作流,根据主题或关键词一键生成高清短视频。Generate HD short videos from a topic or keyword with an automated AI workflow.

fix(cli): reject null batch runtime fields

YANG10240bfb0bcadea4
diff --git a/cli.py b/cli.py
index 4f028c66..376d67b1 100644
--- a/cli.py
+++ b/cli.py
@@ -933,6 +933,15 @@ def _validate_batch_task_params(
raise ValueError(
"video_source must be one of: pexels, pixabay, coverr, local"
)
+ for field_name, value in (
+ ("video_aspect", params.video_aspect),
+ ("video_concat_mode", params.video_concat_mode),
+ ):
+ # These schema fields remain Optional for compatibility with historical
+ # API payloads, but the video pipeline always dereferences their enum
+ # values. A manifest's explicit null must fail before any batch task starts.
+ if value is None:
+ raise ValueError(f"{field_name} cannot be null")
if params.video_source == "local" and stop_at == "terms":
raise ValueError(
"stop_at=terms has no effect with video_source=local"
diff --git a/test/services/test_cli.py b/test/services/test_cli.py
index 6ef1b945..4ca246fc 100644
--- a/test/services/test_cli.py
+++ b/test/services/test_cli.py
@@ -956,6 +956,36 @@ class TestCli(unittest.TestCase):
self.assertEqual(code, 2)
start.assert_not_called()
+ def test_later_null_runtime_field_prevents_every_batch_task_from_starting(self):
+ for field_name in ("video_aspect", "video_concat_mode"):
+ with self.subTest(field_name=field_name), tempfile.TemporaryDirectory() as temp_dir:
+ manifest = Path(temp_dir) / "tasks.json"
+ manifest.write_text(
+ json.dumps(
+ [
+ {"video_subject": "valid first task"},
+ {
+ "video_subject": "invalid later task",
+ field_name: None,
+ },
+ ]
+ ),
+ encoding="utf-8",
+ )
+ with patch("app.services.task.start") as start:
+ code = cli.run_cli(
+ [
+ "--batch-file",
+ str(manifest),
+ "--stop-at",
+ "video",
+ "--no-subtitle-enabled",
+ ]
+ )
+
+ self.assertEqual(code, 2)
+ start.assert_not_called()
+
def test_batch_manifest_limits_size_and_task_count(self):
with tempfile.TemporaryDirectory() as temp_dir:
oversized = Path(temp_dir) / "oversized.jsonl"