zylon-ai/private-gpt · error · RuntimeError
File transfer failed: {e}
Error message
File transfer failed: {e} What it means
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.
Source
Thrown at private_gpt/components/tabular/pandasai_sandbox.py:508
_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:
_content = _f.read()
print("FILE_CONTENT_START")
print(_content)
print("FILE_CONTENT_END")View on GitHub (pinned to 4a030776a3)
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.
Example fix
# before
sandbox.transfer_file(df, "ctx.csv")
# after
try:
sandbox.transfer_file(df, "ctx.csv")
except RuntimeError as e:
logger.warning("Transfer failed (%s); restarting sandbox and retrying", e)
sandbox.stop()
sandbox.start()
sandbox.transfer_file(df, "ctx.csv") Defensive patterns
Strategy: retry
Try / catch
try:
sandbox.transfer_file(df, "ctx.csv")
except RuntimeError as e:
logger.warning("transfer failed, restarting sandbox: %s", e)
sandbox.stop(); sandbox.start()
sandbox.transfer_file(df, "ctx.csv") # one retry only Prevention
- 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
When it happens
Trigger: 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).
Common situations: Sandbox session timed out between start() and transfer_file(); network instability to the sandbox service; non-serializable cell values in the dataframe.
Related errors
- Failed to start sandbox: {e}
- Code execution failed: {message}
- Sandbox not started
- File transfer failed: {result.error}
- Path '{canonical_path}' does not match any session mount.
AI-assisted analysis of zylon-ai/private-gpt@4a030776a3 (2026-08-15).
Data as JSON: /api/errors/21c2aace7c0e8ff6.
Report an issue: GitHub.