calesthio/OpenMontage · error · ValueError

{spec['operation']} requires at least one source image

Error message

{spec['operation']} requires at least one source image

What it means

ValueError raised in _build_payload when a multi-image ('images' media_style) model receives zero source images. The list built from image_urls plus an optional leading image_url is empty, so the operation cannot run — these models are image-to-image/edit style and have no zero-input mode.

Source

Thrown at tools/graphics/atlas_image.py:167

        if style == "star":
            payload["size"] = f"{width}*{height}"
        elif style == "x":
            payload["size"] = f"{width}x{height}"
        elif style == "ratio":
            payload["aspect_ratio"] = inputs.get("aspect_ratio") or atlas_client.aspect_ratio_from_size(
                width, height, _COMMON_RATIOS
            )
        elif style == "tier":
            payload["size"] = inputs.get("resolution", "auto")

        images = list(inputs.get("image_urls") or [])
        if inputs.get("image_url"):
            images.insert(0, inputs["image_url"])
        media_style = spec["media_style"]
        if media_style == "images":
            maximum = int(spec["max_images"])
            if not images:
                raise ValueError(f"{spec['operation']} requires at least one source image")
            if len(images) > maximum:
                raise ValueError(f"{model} accepts at most {maximum} source images")
            payload["images"] = images
        elif media_style == "image":
            if len(images) != 1:
                raise ValueError("layer decomposition requires exactly one source image")
            payload["image"] = images[0]

        for field in spec.get("optional_fields", ()):
            if inputs.get(field) is not None:
                payload[field] = inputs[field]
        if inputs.get("output_format") and inputs["output_format"] != "default":
            payload["output_format"] = inputs["output_format"]

        extra = inputs.get("extra_params")
        if isinstance(extra, dict):
            payload.update(extra)
        return payload

View on GitHub (pinned to 95e1c3d0ab)

Solutions

  1. Provide at least one accessible image URL via image_urls (or image_url) matching the model's expected input.
  2. If you wanted pure text-to-image, select a generate-mode model instead (see the family/route validation).
  3. Validate non-empty image inputs before calling: `assert inputs.get('image_urls')`.
  4. Ensure URLs are publicly reachable http(s) URLs the Atlas API can fetch.

Example fix

# before
inputs = {"model": "<edit-model>", "prompt": "restyle"}  # no images -> ValueError

# after
inputs = {"model": "<edit-model>", "prompt": "restyle", "image_urls": [uploaded_url]}
Defensive patterns

Strategy: validation

Validate before calling

images = list(inputs.get("image_urls") or [])
if inputs.get("image_url"):
    images.insert(0, inputs["image_url"])
assert images, "edit/reference models require at least one source image URL"

Type guard

def has_source_images(inputs: dict) -> bool:
    return bool(inputs.get("image_urls") or inputs.get("image_url"))

Try / catch

try:
    result = tool.run(inputs)
except ValueError as e:
    if "requires at least one source image" in str(e):
        raise ValueError("Upload an image first and pass its URL via image_urls") from e
    raise

Prevention

When it happens

Trigger: Calling an edit/reference model with neither image_urls nor image_url in inputs, e.g. passing only a prompt, or passing image_urls=None/empty list (falsy values are dropped by `or []`).

Common situations: Reusing a text-to-image call shape for an edit model, forgetting to upload/attach reference images, or upstream code that conditionally sets image_urls and skips it when the list is empty.

Related errors


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