Skip to content

Bug: sequence replacement accepts non-MP4 replacement files #98

Description

@Ahmed-Hindy

Summary

replace_sequence_with_mp4() and the corresponding CLI accept any existing file as the replacement when delete_source=False and verify=False. Despite the API/CLI name and docs requiring an MP4, the code can treat a source .exr frame as the replacement and report success.

Current behavior

The replacement path is only checked for existence unless verification is requested or source deletion is enabled:

if not source_mp4.is_file():
    raise SequenceReplacementError(...)

if dry_run:
    return False, False

if source_mp4 != destination_mp4.resolve():
    shutil.copy2(source_mp4, destination_mp4)

There is no extension or media-type validation for the non-destructive replacement path.

Reproduction

Run this against current origin/main (a582621):

from pathlib import Path
from tempfile import TemporaryDirectory
from renderkit.core.sequence_replacement import replace_sequence_with_mp4

with TemporaryDirectory() as tmp:
    root = Path(tmp)
    for i in range(1, 4):
        (root / f"render.{i:04d}.exr").write_text("frame")

    bad_replacement = root / "render.0001.exr"
    result = replace_sequence_with_mp4(
        str(root / "render.%04d.exr"),
        bad_replacement,
        delete_source=False,
    )
    print("copied_mp4:", result.copied_mp4.name)
    print("copied:", result.copied)

Observed:

copied_mp4: render.0001.exr
copied: False

Expected behavior

Replacement should reject non-MP4 inputs regardless of --delete-source / --verify, or the command should be renamed/documented to accept arbitrary replacement files. Since the workflow is specifically replacing sequences with approved MP4 review movies, validating .mp4 early is safer.

Impact

Users can get a successful audit record for a replacement that is not an MP4. In non-destructive dry-run/planning workflows this can hide staging mistakes until a later cleanup step, and it weakens the safety contract around the replacement command.

Likely fix areas

  • src/renderkit/core/sequence_replacement.py _copy_replacement_mp4() or an earlier validator
  • src/renderkit/cli/main.py replace_sequence_command() and batch_replace_command()
  • Add regression tests for non-MP4 replacement files with and without --delete-source.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions