fix(daytona): upload stdin bytes directly and call delete_file with its real signature
The pinned SDK (daytona 0.155.0) upload_file() accepts bytes, so the host NamedTemporaryFile round-trip was redundant and briefly wrote the merged stdin (which can start with the sudo password line) to the host disk. delete_file() is delete_file(path, recursive=False); the extra request_timeout kwarg raised TypeError inside contextlib.suppress, so the pre-dispatch cancel scrub silently never ran and the staged payload stayed in the sandbox /tmp. Co-authored-by: JoaoMarcos44 <joaomarcosdias444@gmail.com>
This commit is contained in:
@@ -10,7 +10,6 @@ import math
|
||||
import os
|
||||
import shlex
|
||||
import threading
|
||||
import tempfile
|
||||
import uuid
|
||||
from pathlib import Path, PurePosixPath
|
||||
|
||||
@@ -153,7 +152,7 @@ class DaytonaEnvironment(BaseEnvironment):
|
||||
# Uploaded but never dispatched: nothing else will unlink it.
|
||||
# Once dispatched the user shell rm's it before running cmd.
|
||||
with contextlib.suppress(Exception):
|
||||
sandbox.fs.delete_file(state["staged"], request_timeout=5)
|
||||
sandbox.fs.delete_file(state["staged"])
|
||||
with contextlib.suppress(Exception):
|
||||
sandbox.stop()
|
||||
|
||||
@@ -162,12 +161,7 @@ class DaytonaEnvironment(BaseEnvironment):
|
||||
if stdin_data is not None:
|
||||
temp_dir = self.get_temp_dir().rstrip("/") or "/"
|
||||
remote_stdin = f"{temp_dir}/.hermes-stdin-{uuid.uuid4().hex}"
|
||||
with tempfile.NamedTemporaryFile(delete=False) as staged:
|
||||
staged.write(stdin_data.encode("utf-8", "surrogateescape"))
|
||||
try:
|
||||
sandbox.fs.upload_file(staged.name, remote_stdin)
|
||||
finally:
|
||||
os.unlink(staged.name)
|
||||
sandbox.fs.upload_file(stdin_data.encode("utf-8", "surrogateescape"), remote_stdin)
|
||||
with lock:
|
||||
state["staged"] = remote_stdin
|
||||
sandbox.fs.set_file_permissions(remote_stdin, mode="600")
|
||||
|
||||
Reference in New Issue
Block a user