{"record":{"id":"04c67be31a0b6db4","repo":"ATH-MaaS/Pixelle-Video","slug":"ark-api-key-not-set-04c67b","errorCode":null,"errorMessage":"ARK_API_KEY not set.","messagePattern":"ARK_API_KEY not set\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"pixelle_video/services/api_services/video_seedance.py","lineNumber":67,"sourceCode":"        prompt: str,\n        image_path: Optional[str],\n        save_path: str,\n        model: str = \"doubao-seedance-2-0-260128\",\n        duration: int = 5,\n        **kwargs\n    ) -> str:\n        \"\"\"\n        图生视频完整流程\n\n        Args:\n            prompt: 提示词\n            image_path: 输入图片本地路径；为空时走文生视频\n            save_path: 输出视频保存路径\n            model: 模型名称\n            duration: 视频时长\n        \"\"\"\n        if not self.api_key:\n            raise RuntimeError(\"ARK_API_KEY not set.\")\n\n        # 1. 提交任务\n        task_id = self._submit_task(prompt, image_path, model, duration, **kwargs)\n        \n        # 2. 轮询等待\n        video_url = self._poll_until_done(task_id)\n        \n        # 3. 下载视频\n        self._download_video(video_url, save_path)\n        \n        return video_url\n\n    def _submit_task(self, prompt: str, image_path: Optional[str], model: str, duration: int, **kwargs) -> str:\n        # 根据 Seedance 2.0 文档更新接口路径\n        url = f\"{self.base_url}/contents/generations/tasks\"\n\n        # 构建 content 数组\n        content = []","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/ATH-MaaS/Pixelle-Video/blob/848b054e4fae40dabc62ec58e960b573e83793ac/pixelle_video/services/api_services/video_seedance.py#L49-L85","documentation":"SeedanceVideoClient.generate_video throws RuntimeError when self.api_key is falsy before doing any work. The client requires the ARK_API_KEY environment variable to authenticate against the Volcano Engine (Ark) Seedance video-generation API; without it no request can be signed.","triggerScenarios":"Instantiating SeedanceVideoClient without ARK_API_KEY set in the environment (or empty string) and then calling generate_video().","commonSituations":"Developer forgot to export ARK_API_KEY in shell/container; .env file not loaded; CI/CD secrets not injected; typo like ARKAPI_KEY; key set for a different user account than the one running the app.","solutions":["Set the ARK_API_KEY environment variable before running: export ARK_API_KEY=your-key","If using a .env file, ensure it is loaded (e.g. python-dotenv load_dotenv()) and contains ARK_API_KEY","Verify the key is present at process start: python -c \"import os; print(bool(os.environ.get('ARK_API_KEY')))\"","If the client accepts an api_key argument, pass it explicitly instead of relying on the environment"],"exampleFix":"// before\npython generate.py   # ARK_API_KEY not set\n// after\nexport ARK_API_KEY=\"your-volcano-engine-key\"\npython generate.py","handlingStrategy":"validation","validationCode":"import os\nif not os.environ.get(\"ARK_API_KEY\"):\n    raise SystemExit(\"Set ARK_API_KEY before running\")","typeGuard":null,"tryCatchPattern":"try:\n    client.generate_video(prompt=p, image_path=img, save_path=out)\nexcept RuntimeError as e:\n    if \"ARK_API_KEY\" in str(e):\n        logging.critical(\"Missing ARK_API_KEY; configure the environment\")\n    else:\n        raise","preventionTips":["Fail fast at process startup with an env-var presence check","Keep all secrets in .env and load it before any client construction","Add ARK_API_KEY to CI/CD secret injection and container env templates"],"tags":["api-key","environment","configuration","seedance"],"backgroundTag":"missing-env-var","analyzedSha":"848b054e4fae40dabc62ec58e960b573e83793ac","analyzedAt":"2026-08-30T03:24:41.468Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}