"CLI-Anything: Making ALL Software Agent-Native" -- CLI-Hub: https://clianything.cc/
Python
fix(obs-studio): reject NaN in validate_range (#396)
Santhc987d09ee56d
diff --git a/obs-studio/agent-harness/cli_anything/obs_studio/tests/test_validate_range_nan.py b/obs-studio/agent-harness/cli_anything/obs_studio/tests/test_validate_range_nan.pynew file mode 100644index 000000000..1f6e1043c--- /dev/null+++ b/obs-studio/agent-harness/cli_anything/obs_studio/tests/test_validate_range_nan.py@@ -0,0 +1,21 @@+"""validate_range must reject non-finite opacity-like values."""++from __future__ import annotations++import pytest++from cli_anything.obs_studio.utils.obs_utils import validate_range+++def test_nan_rejected() -> None:+ with pytest.raises(ValueError, match="finite"):+ validate_range(float("nan"), 0.0, 1.0, "Opacity")+++def test_inf_rejected() -> None:+ with pytest.raises(ValueError, match="finite"):+ validate_range(float("inf"), 0.0, 1.0, "Opacity")+++def test_in_range_ok() -> None:+ assert validate_range(0.5, 0.0, 1.0, "Opacity") == 0.5diff --git a/obs-studio/agent-harness/cli_anything/obs_studio/utils/obs_utils.py b/obs-studio/agent-harness/cli_anything/obs_studio/utils/obs_utils.pyindex 7c6f90a7b..cb445b8b7 100644--- a/obs-studio/agent-harness/cli_anything/obs_studio/utils/obs_utils.py+++ b/obs-studio/agent-harness/cli_anything/obs_studio/utils/obs_utils.py@@ -1,6 +1,7 @@"""OBS Studio CLI - JSON helpers and utilities."""import json+import mathimport osimport copyfrom typing import Dict, Any, List, Optional@@ -27,6 +28,8 @@ def unique_name(name: str, items: List[Dict[str, Any]], key: str = "name") -> stdef validate_range(value: float, min_val: float, max_val: float, name: str) -> float:"""Validate that a value is within range."""val = float(value)+ if not math.isfinite(val):+ raise ValueError(f"{name} must be a finite number, got {val}")if val < min_val or val > max_val:raise ValueError(f"{name} must be between {min_val} and {max_val}, got {val}")return val