fix(daytona): don't guess /root on cwd probe failure, keep constructor default; update tests to reflect this
Signed-off-by: rovle <lovre.pesut@gmail.com>
This commit is contained in:
parent
4f1464b3af
commit
efc7a7b957
2 changed files with 7 additions and 6 deletions
|
|
@ -115,15 +115,15 @@ class TestCwdResolution:
|
||||||
env = make_env(cwd="/workspace", home_dir="/root")
|
env = make_env(cwd="/workspace", home_dir="/root")
|
||||||
assert env.cwd == "/workspace"
|
assert env.cwd == "/workspace"
|
||||||
|
|
||||||
def test_home_detection_failure_falls_back_to_root(self, make_env):
|
def test_home_detection_failure_keeps_default_cwd(self, make_env):
|
||||||
sb = _make_sandbox()
|
sb = _make_sandbox()
|
||||||
sb.process.exec.side_effect = RuntimeError("exec failed")
|
sb.process.exec.side_effect = RuntimeError("exec failed")
|
||||||
env = make_env(sandbox=sb)
|
env = make_env(sandbox=sb)
|
||||||
assert env.cwd == "/root"
|
assert env.cwd == "/home/daytona" # keeps constructor default
|
||||||
|
|
||||||
def test_empty_home_falls_back_to_root(self, make_env):
|
def test_empty_home_keeps_default_cwd(self, make_env):
|
||||||
env = make_env(home_dir="")
|
env = make_env(home_dir="")
|
||||||
assert env.cwd == "/root"
|
assert env.cwd == "/home/daytona" # keeps constructor default
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -98,9 +98,10 @@ class DaytonaEnvironment(BaseEnvironment):
|
||||||
if self._requested_cwd in ("~", "/home/daytona"):
|
if self._requested_cwd in ("~", "/home/daytona"):
|
||||||
try:
|
try:
|
||||||
home = self._sandbox.process.exec("echo $HOME").result.strip()
|
home = self._sandbox.process.exec("echo $HOME").result.strip()
|
||||||
self.cwd = home or "/root"
|
if home:
|
||||||
|
self.cwd = home
|
||||||
except Exception:
|
except Exception:
|
||||||
self.cwd = "/root"
|
pass # leave cwd as-is; sandbox will use its own default
|
||||||
logger.info("Daytona: resolved cwd to %s", self.cwd)
|
logger.info("Daytona: resolved cwd to %s", self.cwd)
|
||||||
|
|
||||||
def _ensure_sandbox_ready(self):
|
def _ensure_sandbox_ready(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue