fix(gateway): skip local workdir resolution for remote node execution#50961
fix(gateway): skip local workdir resolution for remote node execution#50961obviyus merged 3 commits intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR fixes a cross-platform remote execution failure where the gateway was incorrectly using The one-line fix ( Key observations:
Confidence Score: 4/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/agents/bash-tools.exec.ts
Line: 360-362
Comment:
**Missing inline comment for non-obvious branch**
The surrounding codebase consistently adds a brief comment before analogous `host === "node"` guard conditions — for example, lines 392–393 explain why `pathPrepend` is skipped for node hosts. This `else if (host !== "node")` change is equally non-obvious (why skip `resolveWorkdir` for nodes?) and would benefit from the same treatment to aid future readers without requiring them to trace the bug report.
```suggestion
} else if (host !== "node") {
// Skip local workdir resolution for remote node execution: the remote node's
// filesystem is not visible to the gateway, so resolveWorkdir() would incorrectly
// fall back to the gateway's cwd. The node is responsible for validating its own cwd.
workdir = resolveWorkdir(rawWorkdir, warnings);
}
```
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: "fix(gateway): skip l..." |
81da370 to
1abee5d
Compare
1abee5d to
116258b
Compare
obviyus
left a comment
There was a problem hiding this comment.
Reviewed latest changes; landing now.
…openperf) * fix(gateway): skip local workdir resolution for remote node execution * chore: add inline comment for non-obvious node workdir skip * fix: preserve node exec cwd on remote hosts (openclaw#50961) (thanks @openperf) --------- Co-authored-by: Ayaan Zaidi <hi@obviy.us>
…openperf) * fix(gateway): skip local workdir resolution for remote node execution * chore: add inline comment for non-obvious node workdir skip * fix: preserve node exec cwd on remote hosts (openclaw#50961) (thanks @openperf) --------- Co-authored-by: Ayaan Zaidi <hi@obviy.us>
…openperf) * fix(gateway): skip local workdir resolution for remote node execution * chore: add inline comment for non-obvious node workdir skip * fix: preserve node exec cwd on remote hosts (openclaw#50961) (thanks @openperf) --------- Co-authored-by: Ayaan Zaidi <hi@obviy.us>
…openperf) * fix(gateway): skip local workdir resolution for remote node execution * chore: add inline comment for non-obvious node workdir skip * fix: preserve node exec cwd on remote hosts (openclaw#50961) (thanks @openperf) --------- Co-authored-by: Ayaan Zaidi <hi@obviy.us>
…openperf) * fix(gateway): skip local workdir resolution for remote node execution * chore: add inline comment for non-obvious node workdir skip * fix: preserve node exec cwd on remote hosts (openclaw#50961) (thanks @openperf) --------- Co-authored-by: Ayaan Zaidi <hi@obviy.us>
…openperf) * fix(gateway): skip local workdir resolution for remote node execution * chore: add inline comment for non-obvious node workdir skip * fix: preserve node exec cwd on remote hosts (openclaw#50961) (thanks @openperf) --------- Co-authored-by: Ayaan Zaidi <hi@obviy.us>
…openperf) * fix(gateway): skip local workdir resolution for remote node execution * chore: add inline comment for non-obvious node workdir skip * fix: preserve node exec cwd on remote hosts (openclaw#50961) (thanks @openperf) --------- Co-authored-by: Ayaan Zaidi <hi@obviy.us>
Summary
host=nodein a multi-user setup (e.g., Linux gateway to macOS node), the execution fails withexec INVALID_REQUEST: SYSTEM_RUN_DENIED: approval requires canonical cwd (no symlink cwd). This happens even if the working directory on the node is a valid absolute path. The issue originates insrc/agents/bash-tools.exec.tsaround line 361.resolveWorkdir()to thehost=noderequest.resolveWorkdir()usesfs.statSync()to verify if the directory exists on the local gateway filesystem. Since the remote node's path (e.g.,/Users/vv) doesn't exist on the Linux gateway, it falls back to the gateway's localprocess.cwd()orhomedir(). This incorrect fallback path is then sent to the remote node, which subsequently fails the strictresolveCanonicalApprovalCwdSyncchecks during the approval phase on the node side.elsebranch insrc/agents/bash-tools.exec.tstoelse if (host !== "node"). This prevents the gateway from attempting to resolve and validate the working directory locally when the target host is a remote node. The node is now responsible for resolving and validating its owncwd, which is the correct architectural behavior. This fix completely avoids side effects because it only changes the behavior forhost=node, leavinghost=gatewayandhost=sandboxpaths untouched.src/agents/bash-tools.exec.ts: Addedif (host !== "node")condition before callingresolveWorkdir(rawWorkdir, warnings).host=gatewayorhost=sandboxresolve their working directories.resolveCanonicalApprovalCwdSync); the strict security checks on the node remain fully intact.Reproduction
openclaw nodes run --node --cwd /Users/username -- /usr/bin/pwdRisk / Mitigation
host=nodecondition in the exec tool.src/node-host/invoke-system-run-plan.ts) are left untouched, ensuring that security boundaries are maintained at the execution endpoint. The change simply ensures the correct path is passed to those checks.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Fixes #50783
AI-Assisted Contribution