{"record":{"id":"f0352587d6a95d42","repo":"calesthio/OpenMontage","slug":"kling-lip-sync-response-item-contained-no-download","errorCode":null,"errorMessage":"Kling lip-sync response item contained no downloadable URL: {item}","messagePattern":"Kling lip-sync response item contained no downloadable URL: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/avatar/kling_lip_sync.py","lineNumber":677,"sourceCode":"        base_path = Path(inputs.get(\"output_path\", \"kling_lip_sync.mp4\"))\n        paths: list[Path] = []\n        for index, item in enumerate(outputs):\n            url = self._output_url(item)\n            suffix = extension_from_url(url, \".mp4\")\n            output_path = numbered_output_path(output_path_with_suffix(base_path, suffix), index, suffix)\n            client.download(url, output_path)\n            paths.append(output_path)\n        return paths\n\n    @staticmethod\n    def _output_url(item: dict[str, Any]) -> str:\n        url = item.get(\"url\") or item.get(\"video_url\") or item.get(\"resource_url\")\n        if url:\n            return str(url)\n        resource = item.get(\"resource\") or {}\n        if isinstance(resource, dict) and resource.get(\"url\"):\n            return str(resource[\"url\"])\n        raise ValueError(f\"Kling lip-sync response item contained no downloadable URL: {item}\")\n\n    @staticmethod\n    def _copy_common_task_fields(inputs: dict[str, Any], payload: dict[str, Any]) -> None:\n        callback_url = validate_callback_url(inputs.get(\"callback_url\"))\n        if callback_url:\n            payload[\"callback_url\"] = callback_url\n        if inputs.get(\"external_task_id\"):\n            payload[\"external_task_id\"] = inputs[\"external_task_id\"]\n\n    @staticmethod\n    def _callback_result_data(inputs: dict[str, Any], task_id: str) -> dict[str, Any]:\n        callback_url = inputs.get(\"callback_url\")\n        if not callback_url:\n            return {}\n        return {\n            \"callback_url\": str(callback_url),\n            \"callback_requested\": True,\n            \"polling_used\": True,","sourceCodeStart":659,"sourceCodeEnd":695,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/avatar/kling_lip_sync.py#L659-L695","documentation":"Raised by KlingLipSyncTool._output_url when a single output item contains no URL under any known key: url, video_url, resource_url, or resource.url. The item exists but has no downloadable location, so the tool cannot fetch the rendered video. The message embeds the offending item for diagnosis.","triggerScenarios":"An outputs entry that only carries metadata (id, status, thumbnails) because the video asset is still processing or was purged; an upstream schema change introducing a new URL field name the tool does not know; an item whose resource is not a dict.","commonSituations":"Downloading too early after task completion; expired CDN links from a delayed download; Kling API version drift.","solutions":["Log the embedded item dict — it usually reveals the actual field name or a pending/expired status","Wait for the task to be fully complete (not merely 'succeeded' at task level) before downloading, then retry","If a new field name appears (e.g. 'download_url'), map it into item['url'] in your wrapper before the tool reads it, or patch _output_url and report upstream"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"def item_has_url(item) -> bool:\n    if item.get(\"url\") or item.get(\"video_url\") or item.get(\"resource_url\"):\n        return True\n    r = item.get(\"resource\")\n    return isinstance(r, dict) and bool(r.get(\"url\"))\n\nbad = [i for i in outputs if not item_has_url(i)]\nif bad:\n    log.warning(\"output items without URLs: %s\", bad)","typeGuard":"def item_has_url(item) -> bool:\n    if item.get(\"url\") or item.get(\"video_url\") or item.get(\"resource_url\"):\n        return True\n    r = item.get(\"resource\")\n    return isinstance(r, dict) and bool(r.get(\"url\"))","tryCatchPattern":"try:\n    url = extract_output_url(item)\nexcept ValueError:\n    log.warning(\"no URL in item; waiting and re-polling task: %s\", item)\n    outputs = client.wait_for_task(task_id, force_refresh=True).get(\"outputs\", [])\n    # re-attempt extraction once","preventionTips":["Download promptly after task completion before CDN links expire","Log raw output items on failure — they reveal renamed fields or pending status","Map unknown URL fields to item['url'] in your wrapper if the upstream schema drifts"],"tags":["kling","lip-sync","api-response","download"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}