{"record":{"id":"e8c292a102209526","repo":"zylon-ai/private-gpt","slug":"client-not-initialized","errorCode":null,"errorMessage":"Client not initialized","messagePattern":"Client not initialized","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"private_gpt/components/tabular/pandasai_sandbox.py","lineNumber":196,"sourceCode":"                self._run(self._client.close())\n            if self._temp_dir and self._temp_dir.exists():\n                shutil.rmtree(self._temp_dir, ignore_errors=True)\n        except Exception as e:\n            logger.error(\"Error stopping sandbox: %s\", e)\n        finally:\n            self._started = False\n            self._client = None\n            self._temp_dir = None\n\n        logger.debug(\"Remote sandbox session stopped successfully\")\n\n    # ------------------------------------------------------------------\n    # Environment setup\n    # ------------------------------------------------------------------\n\n    def _setup_environment(self) -> None:\n        if not self._client:\n            raise RuntimeError(\"Client not initialized\")\n\n        temp_dir = f\"/tmp/{self._user_id}\"\n        colors_repr = repr(self._CUSTOM_COLORS)\n\n        setup_code = textwrap.dedent(\n            f\"\"\"\n            {self._PREAMBLE}\n\n            CUSTOM_COLORS = {colors_repr}\n\n            plt.rcParams.update({{\n                'figure.facecolor': 'none',\n                'axes.facecolor': 'none',\n                'savefig.transparent': True,\n                'axes.edgecolor': 'none',\n                'axes.linewidth': 0,\n                'xtick.bottom': False,\n                'ytick.left': False,","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/private_gpt/components/tabular/pandasai_sandbox.py#L178-L214","documentation":"Raised by _setup_environment() when it runs before a client exists on the adapter. The method pushes the preamble and matplotlib rcParams into the remote sandbox by executing setup code through self._client; with no client there is nowhere to send the code. In practice only reachable when start() is bypassed or _client was never set, since start() itself guards on the client first.","triggerScenarios":"Calling the internal _setup_environment() directly without start(); subclass or test code that constructs the adapter and invokes setup before injecting a client; calling after stop() nulled _client.","commonSituations":"Unit tests exercising setup logic in isolation; a code path change that calls setup eagerly in __init__; adapter reuse after stop().","solutions":["Always call start() first — it validates the client and invokes _setup_environment in the correct order.","If calling setup directly in tests, inject a stub client before doing so.","Treat this error as an invariant violation: fix the call order rather than catching it."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"def environment_ready(sandbox) -> bool:\n    return sandbox._client is not None and sandbox._started","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat _setup_environment as internal; only enter via start()","In tests, inject a stub client before touching setup"],"tags":["sandbox","internal-api","lifecycle","invariant"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}