{"record":{"id":"79a45a4cd4204db3","repo":"calesthio/OpenMontage","slug":"task-id-is-missing-or-invalid","errorCode":null,"errorMessage":"task_id is missing or invalid","messagePattern":"task_id is missing or invalid","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/video/seedance_ark.py","lineNumber":1351,"sourceCode":"                )\n            time.sleep(interval)\n\n    @staticmethod\n    def _download_video(video_url: str, output_path: Path) -> None:\n        import requests\n\n        response = requests.get(video_url, timeout=120)\n        response.raise_for_status()\n        output_path.parent.mkdir(parents=True, exist_ok=True)\n        partial = output_path.with_name(output_path.name + \".part\")\n        partial.write_bytes(response.content)\n        partial.replace(output_path)\n\n    @staticmethod\n    def _validate_task_id(task_id: Any) -> None:\n        value = str(task_id or \"\")\n        if not SeedanceArkVideo.TASK_ID_PATTERN.fullmatch(value):\n            raise ValueError(\"task_id is missing or invalid\")\n\n    @staticmethod\n    def _raise_for_status(response: Any) -> None:\n        try:\n            response.raise_for_status()\n        except Exception as exc:\n            detail = \"\"\n            try:\n                payload = response.json()\n                error = payload.get(\"error\") if isinstance(payload, dict) else None\n                if isinstance(error, dict):\n                    detail = \": \".join(\n                        str(error.get(key))\n                        for key in (\"code\", \"message\")\n                        if error.get(key)\n                    )\n            except Exception:\n                pass","sourceCodeStart":1333,"sourceCodeEnd":1369,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/video/seedance_ark.py#L1333-L1369","documentation":"ValueError raised by the static _validate_task_id when the value does not fullmatch SeedanceArkVideo.TASK_ID_PATTERN. Ark content-generation task ids follow a fixed format (cgt-YYYYMMDD-... style); this guard rejects empty strings, None, ids from other providers, or ids with whitespace/extra characters before they are interpolated into query and cancel URLs.","triggerScenarios":"Passing None, '', a kling task id (e.g. 'kl_...'), a sora video id, or a truncated/copied-with-newline Ark task id to a status-query or cancel operation.","commonSituations":"Persisting task ids in a generic 'task_id' column shared across providers and routing them to the wrong adapter; deserialization bugs producing empty strings; manual copy-paste from logs picking up trailing spaces.","solutions":["Confirm the id came from an Ark (seedance_ark) creation response, not another video provider.","Strip whitespace and check the id is non-empty before calling.","When storing ids from multiple providers, also store the provider name and dispatch on it.","Re-run a valid TASK_ID_PATTERN.fullmatch(value) check in your own code (mirror the pattern from the class) before invoking the tool."],"exampleFix":"# before\nresult = tool.query(task_id=video_row[\"external_id\"])  # may be a Kling id\n\n# after\nif SeedanceArkVideo.TASK_ID_PATTERN.fullmatch(str(task_id or \"\")):\n    result = tool.query(task_id=task_id)\nelse:\n    result = route_by_provider(video_row)","handlingStrategy":"type-guard","validationCode":"from tools.video.seedance_ark import SeedanceArkVideo\nif not SeedanceArkVideo.TASK_ID_PATTERN.fullmatch(str(task_id or \"\")):\n    raise ValueError(f\"refusing to query non-Ark task id: {task_id!r}\")","typeGuard":"def is_ark_task_id(v) -> bool:\n    from tools.video.seedance_ark import SeedanceArkVideo\n    return bool(SeedanceArkVideo.TASK_ID_PATTERN.fullmatch(str(v or \"\")))","tryCatchPattern":"try:\n    tool.query(task_id)\nexcept ValueError as e:\n    if \"task_id\" in str(e):\n        logger.error(\"wrong provider routing for id %r\", task_id)\n    raise","preventionTips":["Store provider next to task_id in persistence layers.","Strip and validate ids against the pattern before any Ark call."],"tags":["validation","seedance","ark","task-id"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}