{"record":{"id":"b4d859642cb7b69a","repo":"ruvnet/RuView","slug":"ruviewmqttclient-requires-the-paho-mqtt-package","errorCode":null,"errorMessage":"RuViewMqttClient requires the `paho-mqtt` package. Install with `pip install \"wifi-densepose[client]\"` to enable the client extras.","messagePattern":"RuViewMqttClient requires the `paho-mqtt` package\\. Install with `pip install \"wifi-densepose\\[client\\]\"` to enable the client extras\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"python/wifi_densepose/client/mqtt.py","lineNumber":79,"sourceCode":"      tests run in parallel against the same broker).\n    - Subscription wildcards (`+`, `#`) are supported by paho's\n      built-in matcher; we route by exact pattern match against the\n      registered handler.\n    \"\"\"\n\n    def __init__(\n        self,\n        *,\n        broker_host: str = \"localhost\",\n        broker_port: int = 1883,\n        client_id: Optional[str] = None,\n        username: Optional[str] = None,\n        password: Optional[str] = None,\n        keepalive: int = 60,\n        tls: bool = False,\n    ) -> None:\n        if not _PAHO_AVAILABLE:\n            raise ImportError(\n                \"RuViewMqttClient requires the `paho-mqtt` package. Install with \"\n                \"`pip install \\\"wifi-densepose[client]\\\"` to enable the client extras.\"\n            )\n        self.broker_host = broker_host\n        self.broker_port = broker_port\n        self.keepalive = keepalive\n        self._client_id = client_id or f\"wifi-densepose-client-{uuid.uuid4().hex[:12]}\"\n        self._handlers: dict[str, MessageHandler] = {}\n        self._handlers_lock = threading.Lock()\n        self._client = mqtt.Client(\n            callback_api_version=CallbackAPIVersion.VERSION2,\n            client_id=self._client_id,\n            clean_session=True,\n        )\n        if username is not None:\n            self._client.username_pw_set(username, password)\n        if tls:\n            self._client.tls_set()","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/python/wifi_densepose/client/mqtt.py#L61-L97","documentation":"RuViewMqttClient.__init__ raises ImportError when the optional paho-mqtt dependency is absent. The module-level import is guarded via _PAHO_AVAILABLE so the rest of wifi_densepose.client stays importable; the failure is deferred to construction time with instructions to install the `client` extra.","triggerScenarios":"Constructing `RuViewMqttClient(broker_host=...)` in an environment where only the base wifi-densepose wheel is installed (no `[client]` extra) and paho-mqtt is missing.","commonSituations":"Minimal Docker images; prod installs trimmed to `pip install wifi-densepose`; dependency resolvers or lockfiles that drop extras.","solutions":["Install the extra: pip install \"wifi-densepose[client]\"","Or install the dependency directly: pip install paho-mqtt (v2 required — the client uses CallbackAPIVersion.VERSION2)","Add the extra to pyproject/requirements so lockfiles and deploy environments carry it"],"exampleFix":"# before\npip install wifi-densepose\n\n# after\npip install \"wifi-densepose[client]\"","handlingStrategy":"validation","validationCode":"import importlib.util\n\nif importlib.util.find_spec(\"paho\") is None:\n    raise SystemExit(\n        \"paho-mqtt missing; run: pip install 'wifi-densepose[client]'\"\n    )\nfrom wifi_densepose.client import RuViewMqttClient\nclient = RuViewMqttClient(broker_host=\"localhost\")","typeGuard":null,"tryCatchPattern":"try:\n    client = RuViewMqttClient(broker_host=host)\nexcept ImportError as e:\n    log.warning(\"MQTT telemetry disabled: %s\", e)\n    client = None  # degrade to a no-op sink instead of crashing","preventionTips":["Depend on wifi-densepose[client], not the bare package, in deployable environments","Add a CI test that constructs RuViewMqttClient to catch missing extras","Audit Dockerfiles for bare pip installs of the package"],"tags":["python","mqtt","optional-dependency","pip","extras"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}