zylon-ai/private-gpt · error · RuntimeError
File transfer failed: {result.error}
Error message
File transfer failed: {result.error} What it means
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.
Source
Thrown at private_gpt/components/tabular/pandasai_sandbox.py:504
transfer_code = textwrap.dedent(
f"""
import os
os.makedirs({temp_dir!r}, exist_ok=True)
_csv_content = {csv_content!r}
with open({filepath!r}, 'w') as _f:
_f.write(_csv_content)
print("File transferred: {filepath}")
"""
).strip()
try:
result = self._run(
self._client.run_code(
transfer_code, SandboxCodeOptions(language="python")
)
)
if not result.success:
raise RuntimeError(f"File transfer failed: {result.error}")
logger.debug("Successfully transferred file: %s", filename)
except Exception as e:
logger.error("Failed to transfer file %s: %s", filename, e)
raise RuntimeError(f"File transfer failed: {e}") from e
def get_file_content(self, filename: str) -> str | None:
if not self._client:
raise RuntimeError("Sandbox not started")
temp_dir = f"/tmp/{self._user_id}"
filepath = f"{temp_dir}/{filename}"
read_code = textwrap.dedent(
f"""
import os
_filepath = {filepath!r}
if os.path.exists(_filepath):
with open(_filepath, 'r') as _f:View on GitHub (pinned to 4a030776a3)
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.
Example fix
# before sandbox.transfer_file(df, filename="reports/2024/data.csv") # after import os safe_name = os.path.basename(filename) or "file.csv" sandbox.transfer_file(df, filename=safe_name)
Defensive patterns
Strategy: try-catch
Validate before calling
import os
def safe_transfer_args(df, filename: str) -> tuple:
name = os.path.basename(filename) or "file.csv"
assert "\\x00" not in name and "/" not in name and "\\" not in name
return df, name Try / catch
try:
sandbox.transfer_file(df, name)
except RuntimeError as e:
if "File transfer failed" in str(e) and e.__cause__ and "result.success" not in str(e.__cause__):
pass # transport-level, see error 251 handling
raise Prevention
- Sanitize filenames to plain basenames
- Chunk or downsample very large frames before upload
- Monitor sandbox disk usage for the user temp dir
When it happens
Trigger: 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.
Common situations: Large dataframes embedded via repr into the transfer code hitting sandbox memory limits; sandbox images with restrictive /tmp permissions; filenames with '/' from upstream naming.
Related errors
- Path '{path}' is in a read-only mount ('{prefix}').
- Sandbox not started
- File transfer failed: {e}
- Path '{canonical_path}' does not match any session mount.
- File not found: {file_data}
AI-assisted analysis of zylon-ai/private-gpt@4a030776a3 (2026-08-15).
Data as JSON: /api/errors/2936843210fcf825.
Report an issue: GitHub.