{"record":{"id":"76ee9fc8cfdde5b1","repo":"calesthio/OpenMontage","slug":"priority-must-be-between-0-and-9","errorCode":null,"errorMessage":"priority must be between 0 and 9","messagePattern":"priority must be between 0 and 9","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/video/seedance_ark.py","lineNumber":1216,"sourceCode":"            value = str(ref)\n            if not value.startswith((\"https://\", \"http://\", \"asset://\")):\n                raise ValueError(\n                    f\"{label} must be a public/signed URL or asset:// ID; \"\n                    \"Ark does not document video Base64 or local paths\"\n                )\n\n    def _validate_optional_parameters(self, payload: dict[str, Any]) -> None:\n        callback = payload.get(\"callback_url\")\n        if callback is not None and not str(callback).startswith(\n            (\"https://\", \"http://\")\n        ):\n            raise ValueError(\"callback_url must be an http(s) URL\")\n        expires = payload.get(\"execution_expires_after\")\n        if expires is not None and not 3600 <= int(expires) <= 259200:\n            raise ValueError(\"execution_expires_after must be between 3600 and 259200\")\n        priority = payload.get(\"priority\")\n        if priority is not None and not 0 <= int(priority) <= 9:\n            raise ValueError(\"priority must be between 0 and 9\")\n        safety = payload.get(\"safety_identifier\")\n        if safety is not None and len(str(safety)) > 64:\n            raise ValueError(\"safety_identifier must be at most 64 characters\")\n\n    def _validate_request_size(self, payload: dict[str, Any]) -> None:\n        # Base64 dominates request size; summing encoded media is a conservative\n        # lower-cost check that avoids building a second complete JSON string.\n        encoded_bytes = 0\n        for item in payload[\"content\"]:\n            media = (\n                item.get(\"image_url\")\n                or item.get(\"audio_url\")\n                or item.get(\"video_url\")\n                or {}\n            )\n            url = str(media.get(\"url\", \"\"))\n            if url.startswith(\"data:\"):\n                encoded_bytes += len(url.encode(\"ascii\"))","sourceCodeStart":1198,"sourceCodeEnd":1234,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/video/seedance_ark.py#L1198-L1234","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Set priority to an integer between 0 and 9 (9 is highest).","Omit the priority key entirely if scheduling priority is not needed — the validator skips None.","If the value comes from user config, clamp it: max(0, min(9, int(value))) before passing it in."],"exampleFix":"# before\ninputs = {\"prompt\": \"...\", \"priority\": 10}\n\n# after\ninputs = {\"prompt\": \"...\", \"priority\": 9}","handlingStrategy":"validation","validationCode":"priority = inputs.get(\"priority\")\nif priority is not None and not (isinstance(int(priority), int) and 0 <= int(priority) <= 9):\n    inputs[\"priority\"] = max(0, min(9, int(priority)))","typeGuard":"def is_valid_ark_priority(v) -> bool:\n    try:\n        return v is None or 0 <= int(v) <= 9\n    except (TypeError, ValueError):\n        return False","tryCatchPattern":"try:\n    result = tool.run(inputs)\nexcept ValueError as e:\n    if \"priority\" in str(e):\n        inputs[\"priority\"] = 5  # sane default, retry\n        result = tool.run(inputs)\n    else:\n        raise","preventionTips":["Keep provider-specific option dicts in one place per tool instead of sharing a generic options bag.","Clamp user-supplied priority to [0,9] at your config boundary."],"tags":["validation","seedance","ark","parameters"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}