{"record":{"id":"2936843210fcf825","repo":"zylon-ai/private-gpt","slug":"file-transfer-failed-result-error","errorCode":null,"errorMessage":"File transfer failed: {result.error}","messagePattern":"File transfer failed: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"private_gpt/components/tabular/pandasai_sandbox.py","lineNumber":504,"sourceCode":"        transfer_code = textwrap.dedent(\n            f\"\"\"\n            import os\n            os.makedirs({temp_dir!r}, exist_ok=True)\n            _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:","sourceCodeStart":486,"sourceCodeEnd":522,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/private_gpt/components/tabular/pandasai_sandbox.py#L486-L522","documentation":"Raised in transfer_file() when the sandbox transport completed the transfer snippet but reported failure (result.success False); result.error carries the sandbox-side reason (e.g. disk full, permission denied on /tmp/<user_id>, OSError while writing the CSV). The transfer is implemented as generated Python that writes the CSV inside the sandbox, so any filesystem problem inside the sandbox surfaces here.","triggerScenarios":"The in-sandbox write of the CSV fails: temp dir not creatable, disk quota exceeded in the sandbox, filename containing path separators or invalid characters, extremely large CSV causing memory failure during repr-embedding of the content.","commonSituations":"Large dataframes embedded via repr into the transfer code hitting sandbox memory limits; sandbox images with restrictive /tmp permissions; filenames with '/' from upstream naming.","solutions":["Read result.error for the sandbox-side OSError detail.","Sanitize filename to a basename without path separators.","For large frames, chunk the transfer or reduce columns/rows before upload.","If disk-related, prune old files in the sandbox temp dir or raise its storage cap."],"exampleFix":"# before\nsandbox.transfer_file(df, filename=\"reports/2024/data.csv\")\n\n# after\nimport os\nsafe_name = os.path.basename(filename) or \"file.csv\"\nsandbox.transfer_file(df, filename=safe_name)","handlingStrategy":"try-catch","validationCode":"import os\n\ndef safe_transfer_args(df, filename: str) -> tuple:\n    name = os.path.basename(filename) or \"file.csv\"\n    assert \"\\\\x00\" not in name and \"/\" not in name and \"\\\\\" not in name\n    return df, name","typeGuard":null,"tryCatchPattern":"try:\n    sandbox.transfer_file(df, name)\nexcept RuntimeError as e:\n    if \"File transfer failed\" in str(e) and e.__cause__ and \"result.success\" not in str(e.__cause__):\n        pass  # transport-level, see error 251 handling\n    raise","preventionTips":["Sanitize filenames to plain basenames","Chunk or downsample very large frames before upload","Monitor sandbox disk usage for the user temp dir"],"tags":["sandbox","file-transfer","filesystem","large-data"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}