calesthio/OpenMontage · error · ValueError

priority must be between 0 and 9

Error message

priority must be between 0 and 9

What it means

Raised by SeedanceArkVideo._validate_optional_parameters when the optional 'priority' input falls outside the integer range [0, 9]. The Ark API accepts priority as a small integer where higher values mean earlier scheduling; anything negative or above 9 is rejected before the HTTP request is ever sent. This is a fail-fast client-side guard, so no network call or tokens are consumed.

Source

Thrown at tools/video/seedance_ark.py:1216

            value = str(ref)
            if not value.startswith(("https://", "http://", "asset://")):
                raise ValueError(
                    f"{label} must be a public/signed URL or asset:// ID; "
                    "Ark does not document video Base64 or local paths"
                )

    def _validate_optional_parameters(self, payload: dict[str, Any]) -> None:
        callback = payload.get("callback_url")
        if callback is not None and not str(callback).startswith(
            ("https://", "http://")
        ):
            raise ValueError("callback_url must be an http(s) URL")
        expires = payload.get("execution_expires_after")
        if expires is not None and not 3600 <= int(expires) <= 259200:
            raise ValueError("execution_expires_after must be between 3600 and 259200")
        priority = payload.get("priority")
        if priority is not None and not 0 <= int(priority) <= 9:
            raise ValueError("priority must be between 0 and 9")
        safety = payload.get("safety_identifier")
        if safety is not None and len(str(safety)) > 64:
            raise ValueError("safety_identifier must be at most 64 characters")

    def _validate_request_size(self, payload: dict[str, Any]) -> None:
        # Base64 dominates request size; summing encoded media is a conservative
        # lower-cost check that avoids building a second complete JSON string.
        encoded_bytes = 0
        for item in payload["content"]:
            media = (
                item.get("image_url")
                or item.get("audio_url")
                or item.get("video_url")
                or {}
            )
            url = str(media.get("url", ""))
            if url.startswith("data:"):
                encoded_bytes += len(url.encode("ascii"))

View on GitHub (pinned to 95e1c3d0ab)

Solutions

  1. Set priority to an integer between 0 and 9 (9 is highest).
  2. Omit the priority key entirely if scheduling priority is not needed — the validator skips None.
  3. If the value comes from user config, clamp it: max(0, min(9, int(value))) before passing it in.

Example fix

# before
inputs = {"prompt": "...", "priority": 10}

# after
inputs = {"prompt": "...", "priority": 9}
Defensive patterns

Strategy: validation

Validate before calling

priority = inputs.get("priority")
if priority is not None and not (isinstance(int(priority), int) and 0 <= int(priority) <= 9):
    inputs["priority"] = max(0, min(9, int(priority)))

Type guard

def is_valid_ark_priority(v) -> bool:
    try:
        return v is None or 0 <= int(v) <= 9
    except (TypeError, ValueError):
        return False

Try / catch

try:
    result = tool.run(inputs)
except ValueError as e:
    if "priority" in str(e):
        inputs["priority"] = 5  # sane default, retry
        result = tool.run(inputs)
    else:
        raise

Prevention

When it happens

Trigger: Calling the seedance_ark video tool with inputs containing priority=10, priority=-1, or a numeric string like '12'. Also triggered by strings that int() coerces out of range (e.g. '9.5' raises ValueError inside int() before the range check message is produced — that surfaces a different message, but values like '11' hit this one).

Common situations: Agents copying priority values from other provider schemas (some APIs use 0-100 scales), user config files carrying priority from a different tool, or assuming priority 10 = maximum.

Related errors


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