{"record":{"id":"611844bc2e084f7f","repo":"Lightning-AI/pytorch-lightning","slug":"expected-a-list-as-videos-found-type-videos","errorCode":null,"errorMessage":"Expected a list as \"videos\", found {type(videos)}","messagePattern":"Expected a list as \"videos\", found (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/loggers/wandb.py","lineNumber":544,"sourceCode":"\n        metrics = {key: [wandb.Audio(audio, **kwarg) for audio, kwarg in zip(audios, kwarg_list)]}\n        self.log_metrics(metrics, step)  # type: ignore[arg-type]\n\n    @rank_zero_only\n    def log_video(self, key: str, videos: list[Any], step: Optional[int] = None, **kwargs: Any) -> None:\n        \"\"\"Log videos (numpy arrays, or file paths).\n\n        Args:\n            key: The key to be used for logging the video files\n            videos: The list of video file paths, or numpy arrays to be logged\n            step: The step number to be used for logging the video files\n            **kwargs: Optional kwargs are lists passed to each Wandb.Video instance (ex: caption, fps, format).\n\n        Optional kwargs are lists passed to each video (ex: caption, fps, format).\n\n        \"\"\"\n        if not isinstance(videos, list):\n            raise TypeError(f'Expected a list as \"videos\", found {type(videos)}')\n        n = len(videos)\n        for k, v in kwargs.items():\n            if len(v) != n:\n                raise ValueError(f\"Expected {n} items but only found {len(v)} for {k}\")\n        kwarg_list = [{k: kwargs[k][i] for k in kwargs} for i in range(n)]\n\n        import wandb\n\n        metrics = {key: [wandb.Video(video, **kwarg) for video, kwarg in zip(videos, kwarg_list)]}\n        self.log_metrics(metrics, step)  # type: ignore[arg-type]\n\n    @property\n    @override\n    def save_dir(self) -> Optional[str]:\n        \"\"\"Gets the save directory.\n\n        Returns:\n            The path to the save directory.","sourceCodeStart":526,"sourceCodeEnd":562,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/loggers/wandb.py#L526-L562","documentation":"WandbLogger.log_video requires videos to be a Python list; each element is passed to wandb.Video with zipped per-item kwargs. A tensor, numpy array (even a single video), tuple, or path string raises TypeError.","triggerScenarios":"logger.log_image-style call with videos as a (B,T,C,H,W) torch tensor, a single numpy video, or a lone file path string.","commonSituations":"Logging a batch of generated video tensors directly; must split into per-video elements.","solutions":["Wrap into a list: list(video_tensor)","For a single video: logger.log_video([video], ...)","For file paths pass a list of path strings"],"exampleFix":"# before\nlogger.log_video(video_batch_tensor)\n# after\nlogger.log_video(list(video_batch_tensor))","handlingStrategy":"type-guard","validationCode":"videos = [videos] if not isinstance(videos, list) else videos","typeGuard":"def is_video_list(x) -> bool:\n    return isinstance(x, list)","tryCatchPattern":null,"preventionTips":["Never pass raw batch tensors to log_video","Use a normalize wrapper for all wandb media logging"],"tags":["wandb","lightning","logging","video","type-error"],"backgroundTag":"invalid-input-type","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}