{"record":{"id":"39d4a8c81016de50","repo":"ruvnet/RuView","slug":"buffer-size-must-be-positive","errorCode":null,"errorMessage":"buffer_size must be positive","messagePattern":"buffer_size must be positive","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"archive/v1/src/hardware/csi_extractor.py","lineNumber":479,"sourceCode":"        \"\"\"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:\n            self.logger.error(f\"Failed to connect to hardware: {e}\")\n            self.is_connected = False\n            return False","sourceCodeStart":461,"sourceCodeEnd":497,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/archive/v1/src/hardware/csi_extractor.py#L461-L497","documentation":"CSIExtractor._validate_config rejects config['buffer_size'] <= 0 with ValueError('buffer_size must be positive'). The buffer sizes acquisition storage between reads; zero or negative is a configuration error, and the extractor applies no implicit default.","triggerScenarios":"buffer_size: 0 in a minimal config; a -1 'unlimited' sentinel; a computed buffer size (rate * seconds) that rounds or truncates to 0.","commonSituations":"Configs trimmed to the smallest working set; buffer sizes derived from formulas during experimentation; copying configs between deployments with different assumptions.","solutions":["Set a positive buffer size appropriate to the CSI rate (e.g. 1024 frames)","If buffer_size is computed, clamp it to a minimum positive value before construction","Pre-validate the config dict with a helper that mirrors the extractor's constraints"],"exampleFix":"# before\nconfig = {'hardware_type': 'esp32', 'sampling_rate': 100, 'buffer_size': 0, 'timeout': 5.0}\n\n# after\nconfig = {'hardware_type': 'esp32', 'sampling_rate': 100, 'buffer_size': 1024, 'timeout': 5.0}","handlingStrategy":"validation","validationCode":"if 'buffer_size' not in config or not isinstance(config['buffer_size'], int) or config['buffer_size'] <= 0:\n    raise ValueError('buffer_size must be a positive integer')","typeGuard":"def is_positive_int(value) -> bool:\n    return isinstance(value, int) 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":["Clamp computed buffer sizes to a minimum positive value before construction","Never use -1 or 0 as 'unlimited' markers — the extractor has no such mode","Share one config-validation helper across all deployments of CSIExtractor"],"tags":["configuration","validation","setup"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}