{"record":{"id":"35403bf9be5da3b0","repo":"ruvnet/RuView","slug":"sampling-rate-must-be-positive-35403b","errorCode":null,"errorMessage":"sampling_rate must be positive","messagePattern":"sampling_rate must be positive","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"archive/v1/src/hardware/csi_extractor.py","lineNumber":476,"sourceCode":"            raise ValueError(f\"Unsupported hardware type: {self.hardware_type}\")\n    \n    def _validate_config(self, config: Dict[str, Any]) -> None:\n        \"\"\"Validate configuration parameters.\n        \n        Args:\n            config: Configuration to validate\n            \n        Raises:\n            ValueError: If configuration is invalid\n        \"\"\"\n        required_fields = ['hardware_type', 'sampling_rate', 'buffer_size', 'timeout']\n        missing_fields = [field for field in required_fields if field not in config]\n        \n        if missing_fields:\n            raise ValueError(f\"Missing required configuration: {missing_fields}\")\n        \n        if config['sampling_rate'] <= 0:\n            raise ValueError(\"sampling_rate must be positive\")\n        \n        if config['buffer_size'] <= 0:\n            raise ValueError(\"buffer_size must be positive\")\n        \n        if config['timeout'] <= 0:\n            raise ValueError(\"timeout must be positive\")\n    \n    async def connect(self) -> bool:\n        \"\"\"Establish connection to CSI hardware.\n        \n        Returns:\n            True if connection successful, False otherwise\n        \"\"\"\n        try:\n            success = await self._establish_hardware_connection()\n            self.is_connected = success\n            return success\n        except Exception as e:","sourceCodeStart":458,"sourceCodeEnd":494,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/archive/v1/src/hardware/csi_extractor.py#L458-L494","documentation":"CSIExtractor._validate_config rejects config['sampling_rate'] <= 0 with ValueError('sampling_rate must be positive'). The rate drives acquisition cadence, so zero (a common 'unset' sentinel) and negative values are treated as invalid configuration rather than defaulted.","triggerScenarios":"sampling_rate: 0 in a config used before tuning; a negative value from a bad calculation or typo; a derived rate that computed to 0 (e.g. division that underflowed a configured expression).","commonSituations":"Config templates using 0 to mean 'auto' where no auto mode exists; values copied from a different tool with different units; environment-specific configs never revisited.","solutions":["Set a positive rate matching the hardware (e.g. 100 for a ~100 Hz CSI stream)","Resolve 'unset' sentinels to real defaults at the config-loading layer before constructing CSIExtractor","Validate numeric config fields against the same constraints with a helper before construction"],"exampleFix":"# before\nconfig = {'hardware_type': 'esp32', 'sampling_rate': 0, 'buffer_size': 1024, 'timeout': 5.0}\n\n# after\nconfig = {'hardware_type': 'esp32', 'sampling_rate': 100, 'buffer_size': 1024, 'timeout': 5.0}","handlingStrategy":"validation","validationCode":"if 'sampling_rate' not in config or not isinstance(config['sampling_rate'], (int, float)) or config['sampling_rate'] <= 0:\n    raise ValueError('sampling_rate must be a positive number')","typeGuard":"def is_positive_number(value) -> bool:\n    return isinstance(value, (int, float)) and not isinstance(value, bool) and value > 0","tryCatchPattern":"try:\n    extractor = CSIExtractor(config)\nexcept ValueError as e:\n    raise SystemExit(f'extractor config invalid: {e}') from e","preventionTips":["Resolve 0/'auto' sentinels to concrete positive defaults in the config loader","Validate numeric fields with a shared is_positive_number helper before extractor construction","Document the expected unit (Hz) next to the key in config templates"],"tags":["configuration","validation","setup"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}