{"record":{"id":"d43471252ac6c138","repo":"langchain-ai/deepagents","slug":"duration-seconds-must-be-0-got-duration-second","errorCode":null,"errorMessage":"duration_seconds must be > 0, got {duration_seconds!r}","messagePattern":"duration_seconds must be > 0, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/deepagents/deepagents/middleware/_video.py","lineNumber":212,"sourceCode":"\n    if not blocks:\n        end_seconds = offset_seconds + duration\n        msg = f\"No frames decoded for window [{offset_seconds:.3f}s, {end_seconds:.3f}s)\"\n        raise VideoExtractionError(msg)\n    return blocks\n\n\ndef _validate_video_window(*, offset_seconds: float, duration_seconds: float, sampling_rate: float) -> None:\n    \"\"\"Validate the requested sampling window before opening the video.\"\"\"\n    if offset_seconds < 0:\n        msg = f\"offset_seconds must be >= 0, got {offset_seconds!r}\"\n        raise ValueError(msg)\n    if sampling_rate <= 0:\n        msg = f\"sampling_rate must be > 0, got {sampling_rate!r}\"\n        raise ValueError(msg)\n    if duration_seconds <= 0:\n        msg = f\"duration_seconds must be > 0, got {duration_seconds!r}\"\n        raise ValueError(msg)\n\n\ndef _open_video_container(av: Any, content: bytes) -> Any:  # noqa: ANN401  # PyAV types are unavailable without the [video] extra\n    \"\"\"Open a video byte payload, normalizing PyAV's failure modes.\n\n    PyAV typically raises `av.error.InvalidDataError` for malformed inputs,\n    but it falls back to `OSError` when the system ffmpeg library is missing\n    or incompatible. Both surface to callers as `VideoExtractionError` so\n    the middleware does not have to distinguish between them.\n    \"\"\"\n    try:\n        return av.open(io.BytesIO(content))\n    except _video_backend_error_types(av) as exc:  # pragma: no cover - depends on host/input\n        msg = f\"Failed to open video payload: {exc}\"\n        raise VideoExtractionError(msg) from exc\n\n\ndef _video_backend_error_types(av: Any) -> tuple[type[BaseException], ...]:  # noqa: ANN401  # PyAV types are unavailable without the [video] extra","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/deepagents/deepagents/middleware/_video.py#L194-L230","documentation":"`_validate_video_window` requires `duration_seconds` to be strictly positive. A zero or negative window length is meaningless (no frames could be sampled), so the call is rejected with ValueError before opening the video.","triggerScenarios":"Calling `extract_video_frames` with `duration_seconds=0` or negative, e.g. `end - start` where end <= start.","commonSituations":"Slicing logic where the computed window is empty; passing 0 expecting 'to the end'; timestamp pairs out of order.","solutions":["Pass a positive `duration_seconds`","Fix the start/end computation so end > start","If you want the remainder of the video, use a duration at least as large as the remaining length"],"exampleFix":"// before\nduration = segment_end - segment_start  # segment_end <= segment_start\nextract_video_frames(content, offset_seconds=segment_start, duration_seconds=duration)\n// after\nduration = max(0.0, segment_end - segment_start)\nif duration <= 0:\n    return  # empty segment, nothing to sample\nextract_video_frames(content, offset_seconds=segment_start, duration_seconds=duration)","handlingStrategy":"validation","validationCode":"if duration_seconds <= 0:\n    raise ValueError(f\"duration_seconds must be > 0, got {duration_seconds!r}\")","typeGuard":"def is_valid_duration(duration_seconds: float) -> bool:\n    return isinstance(duration_seconds, (int, float)) and duration_seconds > 0","tryCatchPattern":null,"preventionTips":["Ensure end timestamps are strictly greater than start timestamps","Skip empty segments before requesting extraction","Don't pass 0 expecting 'whole video'; pass an explicit positive duration"],"tags":["python","validation","argument-error"],"backgroundTag":"invalid-argument-value","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}