{"record":{"id":"ec57726b3dbb6931","repo":"langchain-ai/deepagents","slug":"sampling-rate-must-be-0-got-sampling-rate-r","errorCode":null,"errorMessage":"sampling_rate must be > 0, got {sampling_rate!r}","messagePattern":"sampling_rate must be > 0, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/deepagents/deepagents/middleware/_video.py","lineNumber":209,"sourceCode":"            raise VideoExtractionError(msg) from exc\n    finally:\n        container.close()\n\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","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/deepagents/deepagents/middleware/_video.py#L191-L227","documentation":"`_validate_video_window` requires a strictly positive `sampling_rate` (frames per second to sample). A zero or negative rate would make the frame interval undefined or backwards, so the library raises ValueError before decoding.","triggerScenarios":"Calling `extract_video_frames` with `sampling_rate=0`, a negative value, or a 0.0 produced by a failed config lookup / division.","commonSituations":"Config file with sampling_rate missing and defaulting to 0; computing fps from metadata that returned 0; sign error in a formula.","solutions":["Pass a positive `sampling_rate` (e.g. 1.0 for one frame per second)","Check the config/default path that supplied 0","Guard with `max(0.1, sampling_rate)` or reject bad config at load time"],"exampleFix":"// before\nextract_video_frames(content, sampling_rate=settings.fps)  # settings.fps == 0\n// after\nif settings.fps <= 0:\n    raise ValueError(f\"configured sampling_rate must be > 0, got {settings.fps}\")\nextract_video_frames(content, sampling_rate=settings.fps)","handlingStrategy":"validation","validationCode":"if sampling_rate <= 0:\n    raise ValueError(f\"sampling_rate must be > 0, got {sampling_rate!r}\")","typeGuard":"def is_valid_sampling_rate(rate: float) -> bool:\n    return isinstance(rate, (int, float)) and rate > 0","tryCatchPattern":null,"preventionTips":["Reject zero/negative rates when loading user config","Never default sampling_rate to 0; pick a positive default like 1.0","Check upstream fps computations for divide-by-zero results"],"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"}