calesthio/OpenMontage · error · ValueError

reference_to_video requires reference_image_urls or referenc

Error message

reference_to_video requires reference_image_urls or reference_image_paths

What it means

Raised when operation=reference_to_video is selected but both reference_image_urls and reference_image_paths are empty. The tool builds a reference_images array from those two inputs; if the combined list is empty it raises ValueError rather than sending a reference-free request, which would not match the requested operation.

Source

Thrown at tools/video/grok_video.py:208

            payload["duration"] = int(inputs.get("duration", 5))
            if inputs.get("aspect_ratio"):
                payload["aspect_ratio"] = inputs["aspect_ratio"]
            if inputs.get("resolution"):
                payload["resolution"] = self._normalize_resolution(inputs["resolution"])

        if operation == "image_to_video":
            image = _normalize_media_ref(inputs.get("image_url"), inputs.get("image_path"))
            if not image:
                raise ValueError("image_to_video requires image_url or image_path")
            payload["image"] = image
        elif operation == "reference_to_video":
            refs = [{"url": url} for url in (inputs.get("reference_image_urls") or [])]
            refs.extend(
                {"url": _file_to_data_uri(path)}
                for path in (inputs.get("reference_image_paths") or [])
            )
            if not refs:
                raise ValueError(
                    "reference_to_video requires reference_image_urls or reference_image_paths"
                )
            payload["reference_images"] = refs
            payload["duration"] = int(inputs.get("duration", 5))
            if inputs.get("aspect_ratio"):
                payload["aspect_ratio"] = inputs["aspect_ratio"]
            if inputs.get("resolution"):
                payload["resolution"] = self._normalize_resolution(inputs["resolution"])

        return payload

    def execute(self, inputs: dict[str, Any]) -> ToolResult:
        api_key = os.environ.get("XAI_API_KEY")
        if not api_key:
            return ToolResult(
                success=False,
                error="XAI_API_KEY not set. " + self.install_instructions,
            )

View on GitHub (pinned to 95e1c3d0ab)

Solutions

  1. Provide at least one entry in reference_image_urls or reference_image_paths.
  2. If migrating from image_to_video, move the image into one of the reference list keys.
  3. Log the reference list length upstream to catch filtering stages that silently drop every candidate.

Example fix

# before
{"operation": "reference_to_video", "prompt": "..."}

# after
{"operation": "reference_to_video", "prompt": "...", "reference_image_urls": ["https://cdn.example.com/ref1.png"]}
Defensive patterns

Strategy: validation

Validate before calling

refs = list(inputs.get("reference_image_urls") or []) + list(inputs.get("reference_image_paths") or [])
if inputs.get("operation") == "reference_to_video" and not refs:
    raise ValueError("reference_to_video: reference list is empty after upstream filtering")

Prevention

When it happens

Trigger: Calling grok_video with operation='reference_to_video' where reference_image_urls is None/[] and reference_image_paths is None/[].

Common situations: Upstream filtering empties the reference list (e.g. all candidates failed a download step); key typos (reference_image_urls vs reference_images); reusing an image_to_video payload without migrating the image field into a reference list.

Related errors


AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15). Data as JSON: /api/errors/18c5d3ec30bc3b81. Report an issue: GitHub.