{"record":{"id":"edbeaf5cd2afd779","repo":"ruvnet/RuView","slug":"failed-to-preprocess-csi-data-e","errorCode":null,"errorMessage":"Failed to preprocess CSI data: {e}","messagePattern":"Failed to preprocess CSI data: (.+?)","errorType":"exception","errorClass":"CSIProcessingError","httpStatus":null,"severity":"error","filePath":"archive/v1/src/core/csi_processor.py","lineNumber":147,"sourceCode":"            CSIProcessingError: If preprocessing fails\n        \"\"\"\n        if not self.enable_preprocessing:\n            return csi_data\n        \n        try:\n            # Remove noise from the signal\n            cleaned_data = self._remove_noise(csi_data)\n            \n            # Apply windowing function\n            windowed_data = self._apply_windowing(cleaned_data)\n            \n            # Normalize amplitude values\n            normalized_data = self._normalize_amplitude(windowed_data)\n            \n            return normalized_data\n            \n        except Exception as e:\n            raise CSIProcessingError(f\"Failed to preprocess CSI data: {e}\")\n    \n    def extract_features(self, csi_data: CSIData) -> Optional[CSIFeatures]:\n        \"\"\"Extract features from CSI data.\n        \n        Args:\n            csi_data: Preprocessed CSI data\n            \n        Returns:\n            Extracted features or None if disabled\n            \n        Raises:\n            CSIProcessingError: If feature extraction fails\n        \"\"\"\n        if not self.enable_feature_extraction:\n            return None\n        \n        try:\n            # Extract amplitude-based features","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/archive/v1/src/core/csi_processor.py#L129-L165","documentation":"CSIProcessingError raised by CSIProcessor.preprocess_csi_data when any exception escapes its internal steps (_remove_noise, _apply_windowing, _normalize_amplitude). It is a wrapper: the original exception is stringified into the message, so inspect the embedded text to find the real cause. The wrapper exists so all preprocessing failures share one catchable type.","triggerScenarios":"Calling processor.preprocess_csi_data(csi_data) with malformed CSIData: empty arrays (size 0 amplitude/phase), arrays with different subcarrier counts between amplitude and phase, 1-D phase where 2-D is expected, or NaN/inf values that break normalization (division by zero norm).","commonSituations":"Feeding the first packet from a cold ESP32 capture where the buffer is empty; simulators generating mismatched amplitude/phase shapes; CSI data truncated by packet loss so last window is ragged; NaNs introduced upstream by log of zero or division by zero in the extractor; test fixtures with synthetic shapes that violate the 2-D (samples x subcarriers) contract.","solutions":["Read the embedded message: `str(e)` contains the original exception — fix that root cause first.","Validate CSIData shape before calling: non-empty 2-D arrays with matching amplitude/phase shapes (see validationCode).","Drop or sanitize NaN/inf: `np.nan_to_num` on amplitude/phase, or reject the packet at ingestion.","If data comes from a capture buffer, wait until at least window_size samples exist before preprocessing."],"exampleFix":"# before\nclean = processor.preprocess_csi_data(csi_data)  # CSIProcessingError: Failed to preprocess CSI data: ...empty...\n\n# after\nif csi_data.amplitude.ndim == 2 and csi_data.amplitude.shape[0] >= processor.window_size:\n    clean = processor.preprocess_csi_data(csi_data)\nelse:\n    logger.warning('skipping undersized CSI batch %s', csi_data.amplitude.shape)","handlingStrategy":"try-catch","validationCode":"def preprocessable(csi_data, min_samples: int) -> bool:\n    amp = getattr(csi_data, 'amplitude', None)\n    pha = getattr(csi_data, 'phase', None)\n    return (\n        amp is not None and pha is not None\n        and getattr(amp, 'ndim', 0) == 2 and getattr(pha, 'ndim', 0) == 2\n        and amp.shape == pha.shape\n        and amp.shape[0] >= min_samples\n        and bool(np.isfinite(amp).all() and np.isfinite(pha).all())\n    )\n\nif preprocessable(csi_data, processor.window_size):\n    clean = processor.preprocess_csi_data(csi_data)","typeGuard":null,"tryCatchPattern":"try:\n    clean = processor.preprocess_csi_data(csi_data)\nexcept CSIProcessingError as e:\n    logger.warning('dropping bad CSI batch (%s): %s',\n                   getattr(csi_data, 'timestamp', '?'), e)\n    continue  # skip this batch, keep the stream alive\n# Do not catch blindly: inspect str(e) root cause before dropping","preventionTips":["Normalize shapes at ingestion: amplitude and phase must be 2-D (samples x subcarriers) with equal shapes.","np.nan_to_num raw CSI before it reaches the processor.","Buffer until >= window_size samples; never feed first partial packets."],"tags":["csi-processing","runtime","numpy","data-quality","wrapper-exception"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}