{"record":{"id":"7af3d8dea49d1bb3","repo":"ruvnet/RuView","slug":"timeout-must-be-positive","errorCode":null,"errorMessage":"timeout must be positive","messagePattern":"timeout must be positive","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"archive/v1/src/hardware/csi_extractor.py","lineNumber":482,"sourceCode":"            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:\n            self.logger.error(f\"Failed to connect to hardware: {e}\")\n            self.is_connected = False\n            return False\n    \n    async def disconnect(self) -> None:\n        \"\"\"Disconnect from CSI hardware.\"\"\"","sourceCodeStart":464,"sourceCodeEnd":500,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/archive/v1/src/hardware/csi_extractor.py#L464-L500","documentation":"CSIExtractor._validate_config rejects config['timeout'] <= 0 with ValueError('timeout must be positive'). The timeout bounds reads/connections, and zero or negative would make every read a non-blocking poll, so it is rejected up front at construction.","triggerScenarios":"timeout: 0 copied from a non-blocking prototype config; a negative value; a unit mismatch where a millisecond value of 0 (or a fraction configured as 0 by an int-casting loader) reaches the extractor.","commonSituations":"Timeouts specified in the wrong unit or cast to int too early; configs migrated from tools that allow 0 to mean 'no timeout'; per-environment overrides never validated.","solutions":["Set a positive timeout in the expected unit (seconds), e.g. 5.0","Pre-validate all numeric config fields before constructing CSIExtractor (see validationCode)","Keep one canonical config template with valid values for every required field"],"exampleFix":"# before\nconfig = {'hardware_type': 'esp32', 'sampling_rate': 100, 'buffer_size': 1024, 'timeout': 0}\n\n# after\nconfig = {'hardware_type': 'esp32', 'sampling_rate': 100, 'buffer_size': 1024, 'timeout': 5.0}","handlingStrategy":"validation","validationCode":"if 'timeout' not in config or not isinstance(config['timeout'], (int, float)) or config['timeout'] <= 0:\n    raise ValueError('timeout must be a positive number (seconds)')","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":["Express timeouts in seconds as positive floats (e.g. 5.0); avoid int-casting loaders that turn 0.5 into 0","Validate timeout with the same positive-number check used for sampling_rate","0 meaning 'no timeout' in other tools does not apply here — substitute a real bound"],"tags":["configuration","validation","setup"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}