calesthio/OpenMontage · error · RuntimeError
{exc}
Error message
{exc} What it means
RuntimeError raised by _raise_for_status when an Ark HTTP response has a non-2xx status. It re-raises the original requests error message (from response.raise_for_status()), augmented with the API's own error code/message parsed from the JSON body when present. This is the single funnel for all HTTP-level failures in the client, so the f-string '{exc}' is the carrier of the underlying detail (e.g. '404 Client Error: ... ; AccessKeyNotFound: invalid api key').
Source
Thrown at tools/video/seedance_ark.py:1370
@staticmethod
def _raise_for_status(response: Any) -> None:
try:
response.raise_for_status()
except Exception as exc:
detail = ""
try:
payload = response.json()
error = payload.get("error") if isinstance(payload, dict) else None
if isinstance(error, dict):
detail = ": ".join(
str(error.get(key))
for key in ("code", "message")
if error.get(key)
)
except Exception:
pass
raise RuntimeError(f"{exc}" + (f"; {detail}" if detail else "")) from exc
@staticmethod
def _task_error(task: dict[str, Any]) -> str:
error = task.get("error")
if isinstance(error, dict):
return ": ".join(
str(error.get(key)) for key in ("code", "message") if error.get(key)
)
return str(error or "")
def _cost_from_task_cny(
self, task: dict[str, Any], inputs: dict[str, Any]
) -> float | None:
usage = task.get("usage") or {}
tokens = usage.get("completion_tokens")
if (
not isinstance(tokens, (int, float))
or not math.isfinite(float(tokens))View on GitHub (pinned to 95e1c3d0ab)
Solutions
- Read the '; code: message' suffix in the error text — it is Ark's own reason and points at the fix.
- 401/403: verify the API key environment variable and that the key has Seedance/Ark permissions.
- 404: check _get_base_url() and the model identifier against current Ark docs.
- 429: reduce concurrency or request quota increase; do not shrink retry backoff.
- 400: dump the request payload and compare against the Ark request schema for that endpoint.
Defensive patterns
Strategy: try-catch
Validate before calling
import os
assert os.environ.get("ARK_API_KEY"), "ARK_API_KEY not set — expect 401 from Ark" Try / catch
try:
result = tool.run(inputs)
except RuntimeError as e:
text = str(e)
if "429" in text:
backoff_and_retry_later()
elif "401" in text or "403" in text or "AccessKey" in text:
raise ConfigError("Ark credentials invalid: " + text)
else:
raise Prevention
- Always read the '; code: message' suffix — it is Ark's authoritative reason.
- Validate credentials and base URL at startup with a cheap call rather than at first generation.
- Track quota month-to-month to anticipate 429s.
When it happens
Trigger: Any 4xx/5xx from Ark: 401/403 bad or unscoped API key, 404 wrong base URL or unknown model/task endpoint, 400 schema violations that escaped client-side validation, 429 quota exhausted after retries are spent.
Common situations: Expired or wrong-environment ARK_API_KEY, using a model name not enabled on the account, region mismatch between key and base URL, or month-end quota exhaustion.
Related errors
- Ark query returned no response
- Ark query returned a non-object response
- Non-JSON response from DashScope API: HTTP {response.status_
- Atlas Cloud returned a non-JSON response: {text[:500]}
- {context} failed with HTTP {status}: {text[:500]}
AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15).
Data as JSON: /api/errors/8262dd2df4c33c22.
Report an issue: GitHub.