{"record":{"id":"8c5a18cb705ccfca","repo":"calesthio/OpenMontage","slug":"ark-api-key-must-contain-only-the-api-key-body-re","errorCode":null,"errorMessage":"ARK_API_KEY must contain only the API Key body; remove the 'Bearer ' prefix","messagePattern":"ARK_API_KEY must contain only the API Key body; remove the 'Bearer ' prefix","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/video/seedance_ark.py","lineNumber":486,"sourceCode":"            \"task_action\": action,\n            \"status\": self.get_status().value,\n            \"would_execute\": False,\n            \"paid_submission\": False,\n            \"api_contract\": {\n                \"create\": f\"POST {self.BASE_URL}/contents/generations/tasks\",\n                \"query\": (\n                    f\"GET {self.BASE_URL}/contents/generations/tasks/{{task_id}}\"\n                ),\n                \"cancel\": (\n                    f\"DELETE {self.BASE_URL}/contents/generations/tasks/{{task_id}}\"\n                ),\n            },\n        }\n        try:\n            base_url = self._get_base_url()\n            api_key = self._get_api_key()\n            if api_key and api_key.lower().startswith(\"bearer \"):\n                raise ValueError(\n                    \"ARK_API_KEY must contain only the API Key body; remove \"\n                    \"the 'Bearer ' prefix\"\n                )\n            result[\"api_contract\"] = {\n                \"create\": (f\"POST {base_url}/contents/generations/tasks\"),\n                \"query\": (f\"GET {base_url}/contents/generations/tasks/{{task_id}}\"),\n                \"cancel\": (f\"DELETE {base_url}/contents/generations/tasks/{{task_id}}\"),\n            }\n            if action in {\"query\", \"cancel\"}:\n                self._validate_task_id(inputs.get(\"task_id\"))\n            else:\n                payload = self._build_payload(inputs)\n                result.update(\n                    {\n                        \"model\": payload[\"model\"],\n                        \"operation\": inputs.get(\"operation\", \"text_to_video\"),\n                        \"resolution\": payload.get(\"resolution\", \"720p\"),\n                        \"ratio\": payload.get(\"ratio\", \"16:9\"),","sourceCodeStart":468,"sourceCodeEnd":504,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/video/seedance_ark.py#L468-L504","documentation":"Raised inside `dry_run` when `ARK_API_KEY` starts with the literal prefix 'Bearer ' (case-insensitive): the Ark client adds its own Authorization header formatting, so the env var must contain only the raw API key body. Including the prefix would produce a doubled 'Bearer Bearer ...' header and 401s from Ark. The same condition in `get_status()` merely marks the tool UNAVAILABLE; dry_run surfaces the actionable message instead.","triggerScenarios":"Setting `ARK_API_KEY=\"Bearer sk-xxxx\"` by copy-pasting the full Authorization header value from curl examples or API docs; secrets managers storing the header rather than the key.","commonSituations":"Copy-paste from Volcengine docs that show `Authorization: Bearer <key>`; users applying OpenAI-style conventions where the header is stored whole; shell history autocompleting a previous header export.","solutions":["Strip the prefix: `export ARK_API_KEY=sk-xxxx` (no 'Bearer ', no quotes needed)","If the key lives in a secrets manager, store only the key body","Quick check: `echo \"$ARK_API_KEY\" | head -c 7` should not print 'Bearer '"],"exampleFix":"# before\nexport ARK_API_KEY=\"Bearer 2c0f4f8a-xxxx-xxxx\"\n# after\nexport ARK_API_KEY=\"2c0f4f8a-xxxx-xxxx\"","handlingStrategy":"validation","validationCode":"api_key = os.environ.get(\"ARK_API_KEY\", \"\")\nif api_key.lower().startswith(\"bearer \"):\n    os.environ[\"ARK_API_KEY\"] = api_key[len(\"bearer \"):].strip()\n    # or fail loudly:\n    # raise ValueError(\"ARK_API_KEY must not include 'Bearer ' prefix\")","typeGuard":"def is_bare_api_key(key: str) -> bool:\n    return bool(key) and not key.lower().startswith(\"bearer \")","tryCatchPattern":null,"preventionTips":["Store only the key body in secrets managers and .env","Run tool.get_status() during preflight — it reports UNAVAILABLE for a Bearer-prefixed key, catching this before any call"],"tags":["seedance","ark","authentication","environment","configuration"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}