fix: apply isolation namespace to shell execute cwd (#2329) [FaaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH] - #2435
Conversation
…) [FaaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH]
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Fix correctly applies namespace isolation on top of shellCwd instead of bypassing it when shellCwd is set.
Analysis
Previously, resolveExecuteCwd() returned shellCwd directly when it was non-null, skipping namespace resolution entirely. This meant that under IsolationScope.SESSION or IsolationScope.USER, shell commands executed with an explicit shellCwd would escape the isolation namespace — a correctness bug.
The fix extracts a base path (preferring shellCwd over getCwd()) and then applies namespace segments on top, ensuring isolation is always enforced.
Verdict
Clean, minimal fix. Logic is correct. Build passes.
Note: #2434 appears to be a duplicate of this PR for the same issue (#2329). Consider closing one.
Description
When
IsolationScope.SESSIONorIsolationScope.USERis configured, theLocalFilesystemWithShellcorrectly creates a namespace-aware working directory (e.g.,<workspace>/<sessionId>/). However, theresolveExecuteCwd()method short-circuits whenshellCwdis set (the project root), returningshellCwddirectly without applying the namespace prefix. This causes shell commands to run in the project root instead of the isolated session directory, leading to failures when the agent tries to execute scripts that were generated in the isolated workspace.Root Cause
In
LocalFilesystemWithShell.resolveExecuteCwd():When
shellCwdis set (to the project root), the method returns immediately without checking theNamespaceFactory, so the shell always runs in the project root regardless of the configured isolation scope.Fix
Use
shellCwd(orgetCwd()as fallback) as the base path, then apply namespace resolution on top of it:This ensures that when isolation scope is configured, the shell's working directory becomes
<projectRoot>/<sessionId>/(or<workspace>/<sessionId>/) instead of<projectRoot>/.Testing
LocalFilesystemUserIsolationExampleTestandSandboxFilesystemIsolationScopeExampleTestshould pass with this fixexecute_shell_commandwill now correctly resolve to the isolated namespace directoryFixes #2329