{"record":{"id":"287b125eec2075e7","repo":"ruvnet/RuView","slug":"interface-self-interface-not-found-in-proc-net","errorCode":null,"errorMessage":"Interface {self._interface} not found in /proc/net/wireless","messagePattern":"Interface (.+?) not found in /proc/net/wireless","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"archive/v1/src/sensing/rssi_collector.py","lineNumber":278,"sourceCode":"        \"\"\"Parse /proc/net/wireless for the configured interface.\"\"\"\n        try:\n            with open(\"/proc/net/wireless\", \"r\") as f:\n                for line in f:\n                    if self._interface in line:\n                        # Format: iface: status quality signal noise ...\n                        parts = line.split()\n                        # parts[0] = \"wlan0:\", parts[2]=quality, parts[3]=signal, parts[4]=noise\n                        quality_raw = float(parts[2].rstrip(\".\"))\n                        signal_raw = float(parts[3].rstrip(\".\"))\n                        noise_raw = float(parts[4].rstrip(\".\"))\n                        # Normalise quality to 0..1 (max is typically 70)\n                        quality = min(1.0, max(0.0, quality_raw / 70.0))\n                        return signal_raw, noise_raw, quality\n        except (FileNotFoundError, IndexError, ValueError) as exc:\n            raise RuntimeError(\n                f\"Failed to read /proc/net/wireless for {self._interface}: {exc}\"\n            ) from exc\n        raise RuntimeError(\n            f\"Interface {self._interface} not found in /proc/net/wireless\"\n        )\n\n    def _read_iw_station(self) -> tuple[int, int, int]:\n        \"\"\"Run ``iw dev <iface> station dump`` and parse TX/RX/retries.\"\"\"\n        try:\n            result = subprocess.run(\n                [\"iw\", \"dev\", self._interface, \"station\", \"dump\"],\n                capture_output=True,\n                text=True,\n                timeout=2.0,\n            )\n            text = result.stdout\n\n            tx_bytes = self._extract_int(text, r\"tx bytes:\\s*(\\d+)\")\n            rx_bytes = self._extract_int(text, r\"rx bytes:\\s*(\\d+)\")\n            retries = self._extract_int(text, r\"tx retries:\\s*(\\d+)\")\n            return tx_bytes, rx_bytes, retries","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/archive/v1/src/sensing/rssi_collector.py#L260-L296","documentation":"_read_proc_wireless() finished iterating every line of /proc/net/wireless without finding one containing the configured interface name, so it raises RuntimeError. Unlike the is_available() failure (raised at start time), this happens at sample time: the interface was acceptable earlier (or validation was skipped) and has since disappeared from the procfs table, or the name never matched any row.","triggerScenarios":"The WiFi interface went down, was rfkill-blocked, or was re-enumerated between start() and collect_once(); the driver unregistered the wiphy; a name that does not literally appear in any row (typo or alternate naming) slipped past validation because it substring-matched during is_available but the table changed.","commonSituations":"Suspend/resume or WiFi restarts during long-running collection; USB adapters dropping off the bus; network-manager recreating the interface; running after 'ip link set wlan0 down'.","solutions":["Inspect the current table with 'cat /proc/net/wireless' and confirm the interface row exists.","Bring the interface back up and associate with an AP, then recreate and start the collector.","Stop the collector on repeated sample failures and re-run is_available() before restarting.","Pin the interface name explicitly instead of relying on auto-detection across re-enumeration."],"exampleFix":"# before\nsample = collector.collect_once()  # RuntimeError: Interface wlan0 not found in /proc/net/wireless\n\n# after\nok, reason = LinuxWifiCollector.is_available(interface)\nif not ok:\n    collector.stop()\n    raise RuntimeError(f're-validate failed: {reason}')\nsample = collector.collect_once()","handlingStrategy":"validation","validationCode":"ok, reason = LinuxWifiCollector.is_available(interface)\nif not ok:\n    raise RuntimeError(f'cannot sample, interface unavailable: {reason}')\nsample = collector.collect_once()","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Re-validate the interface with is_available() right before direct collect_once() calls in long-lived processes.","Restart the collector (stop + new instance + start) after WiFi state changes instead of reusing a stale instance.","Monitor for repeated sample failures and recycle the collector process when the interface keeps disappearing."],"tags":["linux","wifi","rssi","interface","sampling"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}