{"record":{"id":"bb3924b552df97a5","repo":"calesthio/OpenMontage","slug":"ark-base-url-must-be-an-https-url","errorCode":null,"errorMessage":"ARK_BASE_URL must be an https:// URL","messagePattern":"ARK_BASE_URL must be an https:// URL","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/video/seedance_ark.py","lineNumber":360,"sourceCode":"        \"reference_video_urls\",\n        \"reference_audio_urls\",\n    ]\n    side_effects = [\n        \"submits a paid task to the Volcengine Ark API\",\n        \"writes the completed video to output_path\",\n    ]\n    user_visible_verification = [\n        \"Watch the downloaded clip for visual continuity and synchronized audio\",\n        \"Confirm the local artifact before the 24-hour remote URL expires\",\n    ]\n\n    def _get_api_key(self) -> str | None:\n        return os.environ.get(\"ARK_API_KEY\")\n\n    def _get_base_url(self) -> str:\n        base_url = os.environ.get(\"ARK_BASE_URL\", self.BASE_URL).rstrip(\"/\")\n        if not base_url.startswith(\"https://\"):\n            raise ValueError(\"ARK_BASE_URL must be an https:// URL\")\n        return base_url\n\n    def get_status(self) -> ToolStatus:\n        api_key = self._get_api_key()\n        if not api_key or api_key.lower().startswith(\"bearer \"):\n            return ToolStatus.UNAVAILABLE\n        return ToolStatus.AVAILABLE\n\n    def estimate_token_usage(self, inputs: dict[str, Any]) -> int:\n        \"\"\"Estimate billable completion tokens using Ark's published formula.\"\"\"\n        _, variant = self._resolve_model(inputs)\n        max_duration = 30 if variant == \"2.5\" else 15\n        duration = self._normalize_duration(inputs.get(\"duration\", 5), max_duration)\n        output_seconds = max_duration if duration == -1 else duration\n        video_refs = list(inputs.get(\"reference_video_urls\") or [])\n        if inputs.get(\"reference_video_url\"):\n            video_refs.append(inputs[\"reference_video_url\"])\n        video_durations = list(inputs.get(\"reference_video_durations\") or [])","sourceCodeStart":342,"sourceCodeEnd":378,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/video/seedance_ark.py#L342-L378","documentation":"Raised by SeedanceArk's `_get_base_url()`: the effective Ark base URL — from `ARK_BASE_URL` env var or the class default — must start with `https://`. The check runs after `rstrip('/')` and exists because the Ark API sends the API key in headers; a plain-http base would leak `ARK_API_KEY` in cleartext, and a malformed value (missing scheme, `http://`, a bare host) would produce broken request URLs.","triggerScenarios":"Setting `ARK_BASE_URL=http://ark.cn-beijing.volces.com` (http scheme); a value with a typo like `ark.cn-beijing.volces.com` (no scheme); a proxy URL with `socks://` or another scheme; trailing content that breaks the prefix check.","commonSituations":"Using an internal HTTP proxy during development; copying a base URL from docs that omits the scheme; pointing at a self-hosted gateway; CI environments injecting a different base URL variable.","solutions":["Set `ARK_BASE_URL` to the full https URL, e.g. `https://ark.cn-beijing.volces.com/api/v3`","If you must use a local HTTP dev gateway, terminate TLS locally (e.g. via an https reverse proxy) rather than downgrading the scheme","Remove the variable entirely to fall back to the class default `BASE_URL`, which is https"],"exampleFix":"# before\nexport ARK_BASE_URL=\"ark.cn-beijing.volces.com/api/v3\"\n# after\nexport ARK_BASE_URL=\"https://ark.cn-beijing.volces.com/api/v3\"","handlingStrategy":"validation","validationCode":"import os\nbase = os.environ.get(\"ARK_BASE_URL\", \"\").rstrip(\"/\")\nif base and not base.startswith(\"https://\"):\n    raise ValueError(\"ARK_BASE_URL must start with https:// — refusing to send ARK_API_KEY over plaintext\")","typeGuard":"def is_https_base_url(url: str) -> bool:\n    return isinstance(url, str) and url.startswith(\"https://\")","tryCatchPattern":"try:\n    base_url = tool._get_base_url()\nexcept ValueError as e:\n    raise SystemExit(f\"config error: {e}; fix ARK_BASE_URL\") from e","preventionTips":["Validate ARK_BASE_URL at process start, not at first request","Never 'fix' this by allowing http:// — the check protects ARK_API_KEY from cleartext exposure"],"tags":["seedance","ark","configuration","security","environment"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}