Skip to content

Commit 0bfb0bc

Browse files
committed
fix(cli): reject null batch runtime fields
Reject explicit null video_aspect and video_concat_mode values during all-entry batch preflight so invalid later entries cannot fail after earlier tasks have started.
1 parent 50091bd commit 0bfb0bc

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

cli.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,15 @@ def _validate_batch_task_params(
933933
raise ValueError(
934934
"video_source must be one of: pexels, pixabay, coverr, local"
935935
)
936+
for field_name, value in (
937+
("video_aspect", params.video_aspect),
938+
("video_concat_mode", params.video_concat_mode),
939+
):
940+
# These schema fields remain Optional for compatibility with historical
941+
# API payloads, but the video pipeline always dereferences their enum
942+
# values. A manifest's explicit null must fail before any batch task starts.
943+
if value is None:
944+
raise ValueError(f"{field_name} cannot be null")
936945
if params.video_source == "local" and stop_at == "terms":
937946
raise ValueError(
938947
"stop_at=terms has no effect with video_source=local"

test/services/test_cli.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,36 @@ def test_batch_rejects_invalid_video_clip_speed_before_start(self):
956956
self.assertEqual(code, 2)
957957
start.assert_not_called()
958958

959+
def test_later_null_runtime_field_prevents_every_batch_task_from_starting(self):
960+
for field_name in ("video_aspect", "video_concat_mode"):
961+
with self.subTest(field_name=field_name), tempfile.TemporaryDirectory() as temp_dir:
962+
manifest = Path(temp_dir) / "tasks.json"
963+
manifest.write_text(
964+
json.dumps(
965+
[
966+
{"video_subject": "valid first task"},
967+
{
968+
"video_subject": "invalid later task",
969+
field_name: None,
970+
},
971+
]
972+
),
973+
encoding="utf-8",
974+
)
975+
with patch("app.services.task.start") as start:
976+
code = cli.run_cli(
977+
[
978+
"--batch-file",
979+
str(manifest),
980+
"--stop-at",
981+
"video",
982+
"--no-subtitle-enabled",
983+
]
984+
)
985+
986+
self.assertEqual(code, 2)
987+
start.assert_not_called()
988+
959989
def test_batch_manifest_limits_size_and_task_count(self):
960990
with tempfile.TemporaryDirectory() as temp_dir:
961991
oversized = Path(temp_dir) / "oversized.jsonl"

0 commit comments

Comments
 (0)