{"record":{"id":"62a1de129b122e25","repo":"calesthio/OpenMontage","slug":"dashscope-asr-task-failed-msg","errorCode":null,"errorMessage":"DashScope ASR task failed: {msg}","messagePattern":"DashScope ASR task failed: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"tools/analysis/dashscope_asr.py","lineNumber":326,"sourceCode":"        deadline = time.time() + timeout_seconds\n        headers = {\"Authorization\": f\"Bearer {api_key}\"}\n        while time.time() < deadline:\n            time.sleep(poll_interval)\n            resp = requests_module.get(\n                self.POLL_URL_TEMPLATE.format(task_id=task_id),\n                headers=headers,\n                timeout=(10, 60),\n            )\n            data = self._json_or_raise(resp)\n            self._raise_for_error(resp.status_code, data)\n            status = data.get(\"output\", {}).get(\"task_status\")\n            if status == \"SUCCEEDED\":\n                return data\n            if status == \"FAILED\":\n                msg = data.get(\"output\", {}).get(\n                    \"message\", \"unknown error\"\n                )\n                raise RuntimeError(\n                    f\"DashScope ASR task failed: {msg}\"\n                )\n        raise TimeoutError(\n            f\"DashScope ASR task {task_id} did not finish within \"\n            f\"{timeout_seconds}s\"\n        )\n\n    @staticmethod\n    def _is_public_url(url: str) -> bool:\n        return url.startswith(\"http://\") or url.startswith(\"https://\")\n\n    @staticmethod\n    def _extract_words(\n        transcription: dict[str, Any]\n    ) -> list[dict[str, Any]]:\n        \"\"\"Extract flat word list with timestamps normalized to seconds.\"\"\"\n        words: list[dict[str, Any]] = []\n        for transcript in transcription.get(\"transcripts\", []):","sourceCodeStart":308,"sourceCodeEnd":344,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/analysis/dashscope_asr.py#L308-L344","documentation":"Raised by the DashScope ASR poll loop when output.task_status is FAILED. The message embeds output.message (defaulting to 'unknown error'), which is the service's stated reason for the transcription failure.","triggerScenarios":"Submitting an audio URL that is not publicly reachable (signed URL expired, private bucket, localhost/内网 address); unsupported or corrupt audio format; file too large or too long for the file-transcription limits; invalid parameters like a wrong file_url type.","commonSituations":"Passing pre-signed cloud URLs that expire before DashScope fetches them; local file paths mistaken for URLs; unsupported codecs (e.g. some .m4a variants); exceeding the service's max duration/file size; quota exhausted.","solutions":["Read output.message in the raised error — it names the exact failure (download failed, format unsupported, quota, etc.)","If passing a URL, verify it is publicly accessible (curl it from another host) and unexpired","Convert the audio to a supported format (e.g. 16kHz mono wav/mp3) with ffmpeg before submitting","Check file size/duration against DashScope file-transcription limits and trim or split","Check DashScope console for quota/billing status"],"exampleFix":"# before\npayload['file_urls'] = ['file:///tmp/interview.mp3']  # not fetchable\n\n# after — host the file publicly (or use the service's recommended upload path)\nimport requests\nrequests.head(audio_url, timeout=10).raise_for_status()  # preflight\npayload['file_urls'] = [audio_url]","handlingStrategy":"try-catch","validationCode":"import requests\n\ndef audio_url_fetchable(url: str) -> bool:\n    try:\n        r = requests.head(url, timeout=10, allow_redirects=True)\n        return r.status_code == 200\n    except requests.RequestException:\n        return False","typeGuard":"def is_supported_audio(path: str) -> bool:\n    from pathlib import Path\n    return Path(path).suffix.lower() in {'.wav', '.mp3', '.m4a', '.aac', '.flac', '.ogg'}","tryCatchPattern":"try:\n    result = tool.run(inputs)\nexcept RuntimeError as e:\n    if 'DashScope ASR task failed' in str(e):\n        msg = str(e).split('failed:')[-1].strip()\n        if 'download' in msg.lower():\n            inputs['file_urls'] = [refresh_presigned_url(inputs['file_urls'][0])]\n            result = tool.run(inputs)\n        else:\n            raise\n    else:\n        raise","preventionTips":["Preflight public URLs with a HEAD request before submitting","Use long-lived pre-signed URLs or upload to the service's recommended storage","Convert to supported formats (16kHz mono wav/mp3) with ffmpeg first","Respect file size/duration limits — split long recordings"],"tags":["dashscope","asr","async-task","generation-failed","audio"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}