{"record":{"id":"21c2aace7c0e8ff6","repo":"zylon-ai/private-gpt","slug":"file-transfer-failed-e","errorCode":null,"errorMessage":"File transfer failed: {e}","messagePattern":"File transfer failed: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"private_gpt/components/tabular/pandasai_sandbox.py","lineNumber":508,"sourceCode":"            _csv_content = {csv_content!r}\n            with open({filepath!r}, 'w') as _f:\n                _f.write(_csv_content)\n            print(\"File transferred: {filepath}\")\n        \"\"\"\n        ).strip()\n\n        try:\n            result = self._run(\n                self._client.run_code(\n                    transfer_code, SandboxCodeOptions(language=\"python\")\n                )\n            )\n            if not result.success:\n                raise RuntimeError(f\"File transfer failed: {result.error}\")\n            logger.debug(\"Successfully transferred file: %s\", filename)\n        except Exception as e:\n            logger.error(\"Failed to transfer file %s: %s\", filename, e)\n            raise RuntimeError(f\"File transfer failed: {e}\") from e\n\n    def get_file_content(self, filename: str) -> str | None:\n        if not self._client:\n            raise RuntimeError(\"Sandbox not started\")\n\n        temp_dir = f\"/tmp/{self._user_id}\"\n        filepath = f\"{temp_dir}/{filename}\"\n\n        read_code = textwrap.dedent(\n            f\"\"\"\n            import os\n            _filepath = {filepath!r}\n            if os.path.exists(_filepath):\n                with open(_filepath, 'r') as _f:\n                    _content = _f.read()\n                print(\"FILE_CONTENT_START\")\n                print(_content)\n                print(\"FILE_CONTENT_END\")","sourceCodeStart":490,"sourceCodeEnd":526,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/private_gpt/components/tabular/pandasai_sandbox.py#L490-L526","documentation":"The catch-all wrapper in transfer_file(): any exception during the transfer — including the result.success-failure RuntimeError from line 505, transport errors from _client.run_code, or serialization problems building the transfer code — is logged and re-raised as RuntimeError('File transfer failed: <cause>') with the original chained. The interpolated message identifies the underlying failure.","triggerScenarios":"Transport-level failure calling run_code (connection dropped, sandbox session expired); the inner 'File transfer failed: {result.error}' being re-wrapped; exceptions building the transfer snippet (e.g. csv_content repr failing on exotic dtypes).","commonSituations":"Sandbox session timed out between start() and transfer_file(); network instability to the sandbox service; non-serializable cell values in the dataframe.","solutions":["Check e.__cause__ to distinguish transport failure from in-sandbox write failure (error 250).","For expired sessions: restart the sandbox (start()) and retry the transfer once.","For serialization issues: sanitize the dataframe (drop/convert object columns with non-str values) before transfer.","Keep the interval between start() and transfers short to avoid session expiry."],"exampleFix":"# before\nsandbox.transfer_file(df, \"ctx.csv\")\n\n# after\ntry:\n    sandbox.transfer_file(df, \"ctx.csv\")\nexcept RuntimeError as e:\n    logger.warning(\"Transfer failed (%s); restarting sandbox and retrying\", e)\n    sandbox.stop()\n    sandbox.start()\n    sandbox.transfer_file(df, \"ctx.csv\")","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    sandbox.transfer_file(df, \"ctx.csv\")\nexcept RuntimeError as e:\n    logger.warning(\"transfer failed, restarting sandbox: %s\", e)\n    sandbox.stop(); sandbox.start()\n    sandbox.transfer_file(df, \"ctx.csv\")  # one retry only","preventionTips":["Keep start-to-transfer latency low to avoid session expiry","Distinguish transport vs in-sandbox failure via __cause__","Pre-serialize exotic dtypes to str before transfer"],"tags":["sandbox","file-transfer","wrapper-exception","retry"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}