{"record":{"id":"8a3a4208cc1faf28","repo":"ruvnet/RuView","slug":"window-size-must-be-positive","errorCode":null,"errorMessage":"window_size must be positive","messagePattern":"window_size must be positive","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"archive/v1/src/core/csi_processor.py","lineNumber":114,"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 = ['sampling_rate', 'window_size', 'overlap', 'noise_threshold']\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['window_size'] <= 0:\n            raise ValueError(\"window_size must be positive\")\n        \n        if not 0 <= config['overlap'] < 1:\n            raise ValueError(\"overlap must be between 0 and 1\")\n    \n    def preprocess_csi_data(self, csi_data: CSIData) -> CSIData:\n        \"\"\"Preprocess CSI data for feature extraction.\n        \n        Args:\n            csi_data: Raw CSI data\n            \n        Returns:\n            Preprocessed CSI data\n            \n        Raises:\n            CSIProcessingError: If preprocessing fails\n        \"\"\"\n        if not self.enable_preprocessing:\n            return csi_data","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/archive/v1/src/core/csi_processor.py#L96-L132","documentation":"Raised by CSIProcessor._validate_config during __init__ when window_size is present but <= 0. window_size controls the sliding window length in samples for feature extraction; zero or negative windows would produce empty slices and broken FFT outputs, so construction is rejected immediately.","triggerScenarios":"Constructing CSIProcessor with window_size=0 or negative, e.g. CSIProcessor({'sampling_rate': 100, 'window_size': 0, 'overlap': 0.5, 'noise_threshold': 0.1}). Also fires when window_size is computed as a fraction of a buffer that is empty.","commonSituations":"Deriving window_size from packet count on a cold start with zero packets captured; config templates with 0 placeholders; tuning scripts that sweep values and include 0; window_size derived as `int(duration * rate)` where duration or rate is 0; mismatch between samples-per-burst config and expected window units.","solutions":["Set window_size to a positive number of samples, typically 64–256 for CSI windows.","If window_size is computed from data, guard: `window_size = max(1, min(available_samples, desired))` and skip processing when too few samples exist.","Do not use 0 to mean auto; the validator rejects it — pick an explicit positive value.","Check units: window_size is in samples, not seconds; convert `seconds * sampling_rate` before passing."],"exampleFix":"# before\nwindow = int(0.5 * 0)  # duration misparsed as 0\nconfig = {'sampling_rate': 100, 'window_size': window, 'overlap': 0.5, 'noise_threshold': 0.1}\n\n# after\nwindow = max(1, int(0.5 * 100))  # 50 samples for 0.5 s at 100 Hz\nconfig = {'sampling_rate': 100, 'window_size': window, 'overlap': 0.5, 'noise_threshold': 0.1}","handlingStrategy":"validation","validationCode":"window = int(config.get('window_size', 0))\nif window < 1:\n    window = max(1, min(desired_window, available_samples))\nconfig['window_size'] = window","typeGuard":null,"tryCatchPattern":"try:\n    processor = CSIProcessor(config)\nexcept ValueError as e:\n    if 'window_size must be positive' in str(e):\n        config['window_size'] = 64  # sane default\n        processor = CSIProcessor(config)\n    else:\n        raise","preventionTips":["Convert window duration to samples (seconds * sampling_rate) and guard with max(1, ...).","Do not instantiate the processor until the capture buffer has at least one window of samples.","Keep window_size in samples; document units next to the config key."],"tags":["config","validation","csi-processing","signal-processing"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}