{"record":{"id":"76479868b8f2b92c","repo":"calesthio/OpenMontage","slug":"ark-query-returned-a-non-object-response","errorCode":null,"errorMessage":"Ark query returned a non-object response","messagePattern":"Ark query returned a non-object response","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"tools/video/seedance_ark.py","lineNumber":1294,"sourceCode":"                    timeout=30,\n                )\n                retryable_status = (\n                    response.status_code == 429 or response.status_code >= 500\n                )\n                if retryable_status and attempt < self.retry_policy.max_retries:\n                    time.sleep(self.retry_policy.backoff_seconds * (2**attempt))\n                    continue\n                self._raise_for_status(response)\n                break\n            except requests.RequestException:\n                if attempt >= self.retry_policy.max_retries:\n                    raise\n                time.sleep(self.retry_policy.backoff_seconds * (2**attempt))\n        if response is None:\n            raise RuntimeError(\"Ark query returned no response\")\n        data = response.json()\n        if not isinstance(data, dict):\n            raise RuntimeError(\"Ark query returned a non-object response\")\n        return data\n\n    def _cancel_task(self, task_id: str, api_key: str) -> None:\n        import requests\n\n        response = requests.delete(\n            f\"{self._get_base_url()}/contents/generations/tasks/{task_id}\",\n            headers=self._headers(api_key),\n            timeout=30,\n        )\n        # The official DELETE success body is undefined and may be empty.\n        self._raise_for_status(response)\n\n    def _poll_task(\n        self,\n        task_id: str,\n        api_key: str,\n        inputs: dict[str, Any],","sourceCodeStart":1276,"sourceCodeEnd":1312,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/video/seedance_ark.py#L1276-L1312","documentation":"RuntimeError raised in _query_task when response.json() decodes successfully but is not a JSON object (dict) — e.g. the endpoint returned a JSON array, string, or number. The task query contract requires an object; anything else means the response shape is unusable and the client refuses to guess at fields.","triggerScenarios":"An intermediate proxy or gateway returning a bare JSON array/string, a redirected response from an auth wall serving JSON like \"unauthorized\", or an API change where the task endpoint wraps objects in a list. Note: malformed JSON would raise requests.JSONDecodeError instead — this error is specifically valid-JSON-wrong-shape.","commonSituations":"Corporate proxies rewriting responses, base-URL misconfiguration pointing at a different Ark service version, or HTML-to-JSON content transformation by a CDN edge.","solutions":["Verify _get_base_url() points at the correct Ark endpoint for your region/environment.","Inspect the raw response body (log response.text) to see what JSON shape is actually returned and by whom.","If a proxy is in the path (HTTP_PROXY/HTTPS_PROXY), bypass it for the Ark host and retest.","Check for an SDK/version mismatch: ensure the client's expected API version matches the deployed Ark API."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"from urllib.parse import urlparse\nhost = urlparse(tool._get_base_url()).hostname\nassert \"ark\" in host or \"volces\" in host, f\"suspicious base url: {host}\"","typeGuard":null,"tryCatchPattern":"try:\n    data = tool._query_task(task_id, api_key)\nexcept RuntimeError as e:\n    if \"non-object\" in str(e):\n        logger.error(\"Ark API shape changed; dumping raw body for diagnosis\")\n        raise","preventionTips":["Pin the Ark base URL explicitly in config instead of relying on defaults or proxy rewrites.","Add a contract test asserting the task query returns a dict."],"tags":["network","seedance","ark","json","api-contract"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}