fix(exec): expand leading ~ in workdir to home directory#94449
Conversation
5bd6724 to
710e0ef
Compare
|
@vincentkoc Thanks for the refactor — your version is cleaner than mine. I've reviewed the changes and everything looks good. All CI checks have passed. Is there anything else needed from my side before this gets merged? |
|
Codex review: found issues before merge. Reviewed July 2, 2026, 10:11 PM ET / 02:11 UTC. Summary PR surface: Source +4, Tests +23. Total +27 across 6 files. Reproducibility: yes. for source-level behavior: current main passes gateway workdir strings directly to the host stat check, so Review metrics: 2 noteworthy metrics.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: If maintainers want this follow-on behavior, rebase the branch, keep expansion scoped to gateway-local exec workdirs, and make the shared unavailable-workdir diagnostic accurate for tilde and non-tilde failures across hosts. Do we have a high-confidence way to reproduce the issue? Yes for source-level behavior: current main passes gateway workdir strings directly to the host stat check, so Is this the best way to solve the issue? Not yet. The gateway branch is the right layer if maintainers want tilde expansion, but the already-merged fail-fast behavior fixed the unsafe fallback and this PR still needs conflict resolution, diagnostic repair, and compatibility acceptance. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3ad465d32b3b. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +4, Tests +23. Total +27 across 6 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
710e0ef to
7c1fb87
Compare
710e0ef to
a9bb3dc
Compare
The previous message claimed "~" is not expanded, but this PR adds leading tilde expansion for local (gateway) execution. Update the diagnostic to reflect the new behavior. Ref. openclaw#94449
…tic message Updated expect strings in two test files to match the revised formatUnavailableWorkdirFailure message that correctly describes tilde expansion behavior for local execution. Ref. openclaw#94449
6c15095 to
41565d1
Compare
The previous message claimed "~" is not expanded, but this PR adds leading tilde expansion for local (gateway) execution. Update the diagnostic to reflect the new behavior. Ref. openclaw#94449
…tic message Updated expect strings in two test files to match the revised formatUnavailableWorkdirFailure message that correctly describes tilde expansion behavior for local execution. Ref. openclaw#94449
- Replace String() cast with type assertion to fix no-base-to-string lint - Add generic type param to vi.fn() calls to fix TS2493 tuple access Ref. openclaw#94449
|
@clawsweeper re-review Changes made:
This addresses the P2 finding: make unavailable-workdir guidance host-aware. The message now accurately reflects that tilde expansion is a gateway-local feature, which remains true for all callers (gateway, node, sandbox). |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Summary
exectool does not expand a leading~inworkdir, then falls back to another directory and still executes the command, causing relative commands to run from the wrong location.Root cause:
resolveExecWorkdir()insrc/agents/bash-tools.exec-workdir.tspassed the explicit workdir value directly to the stat check without expanding~/~/to the user's home directory.Fix: Apply
expandHomePrefix()only in the local gateway branch ofresolveExecWorkdir(), after the host-specific node/sandbox branches have returned. This ensures leading~is expanded for localhost=gatewayexecution while node and sandbox workdirs remain untouched.Fixes #94434. Supersedes sibling PRs #94447, #94450, #94462.
Real behavior proof (required for external PRs)
Behavior addressed:
resolveExecWorkdir({host: "gateway", workdir: "~"})now expands~to the home directory before the stat check, instead of treating the tilde as a literal path component.Real setup tested:
73ab101Exact steps or command run after fix:
After-fix evidence:
Observed result after the fix:
~resolves tolocal /home/0668001315— the home directory exists, so tilde expansion succeeds.~/nonexistent-tilde-testreturnsunavailable— tilde was expanded, but the target does not exist./tmpworks unchanged — non-tilde paths are not affected.~/projectpreserves the string as-is (remoteCwd: "~/project") — the tilde is NOT expanded for non-gateway hosts.Host-scoping proof
To confirm node and sandbox workdirs are not affected by the gateway-local tilde expansion:
Test:
resolveExecWorkdir({host: "node", workdir: "~/project"})returns{kind: "node", remoteCwd: "~/project"}— the value is forwarded verbatim to the remote node host without gateway-local rewriting.Test file:
src/agents/bash-tools.exec-workdir.test.tsincludes regression test"preserves leading tilde in node workdirs without local expansion".Tests and validation
Risk checklist
Did user-visible behavior change? (
Yes)exec.workdirwith leading~/~/now expands to home directory for local gateway executionDid config, environment, or migration behavior change? (
No)Did security, auth, secrets, network, or tool execution behavior change? (
No)expandHomePrefix()from the existing home-dir helperWhat is the highest-risk area?
How is that risk mitigated?
~/...values are forwarded verbatimCurrent review state
What is the next action?