Repository navigation
fix:sandbox file path Inconsistency - #14810
luckylhb90 wants to merge 2 commits into
Conversation
| describe("resolveSandboxFilePath", () => { | ||
| const mockSandboxWorkspace: SandboxWorkspaceInfo = { | ||
| workspaceDir: "/opt/openclaw/sandboxes/agent-test-123", | ||
| containerWorkdir: "/workspace", | ||
| workspaceAccess: "rw", | ||
| }; |
There was a problem hiding this comment.
SandboxWorkspaceInfo shape mismatch
SandboxWorkspaceInfo only has { workspaceDir, containerWorkdir } (see src/agents/sandbox/types.ts), but the tests construct it with an extra workspaceAccess field. This should fail TypeScript for this new test file; remove the extra property (or adjust the type) so the test compiles.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/infra/outbound/sandbox-path-resolver.test.ts
Line: 9:14
Comment:
**SandboxWorkspaceInfo shape mismatch**
`SandboxWorkspaceInfo` only has `{ workspaceDir, containerWorkdir }` (see `src/agents/sandbox/types.ts`), but the tests construct it with an extra `workspaceAccess` field. This should fail TypeScript for this new test file; remove the extra property (or adjust the type) so the test compiles.
How can I resolve this? If you propose a fix, please make it concise.| // If path starts with container workdir, convert to host path | ||
| if (filePath.startsWith(sandboxWorkspace.containerWorkdir)) { | ||
| const relativePath = filePath.slice(sandboxWorkspace.containerWorkdir.length); | ||
| return path.join(sandboxWorkspace.workspaceDir, relativePath); | ||
| } |
There was a problem hiding this comment.
Over-broad path prefix check
resolveSandboxFilePath() checks filePath.startsWith(sandboxWorkspace.containerWorkdir) and will treat paths like /workspace2/foo as inside the sandbox when containerWorkdir is /workspace. That will incorrectly rewrite legitimate paths that merely share the prefix. This should be restricted to the exact workdir (/workspace) or a /workspace/ boundary to avoid mis-resolving unrelated paths.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/infra/outbound/sandbox-path-resolver.ts
Line: 25:29
Comment:
**Over-broad path prefix check**
`resolveSandboxFilePath()` checks `filePath.startsWith(sandboxWorkspace.containerWorkdir)` and will treat paths like `/workspace2/foo` as inside the sandbox when `containerWorkdir` is `/workspace`. That will incorrectly rewrite legitimate paths that merely share the prefix. This should be restricted to the exact workdir (`/workspace`) or a `/workspace/` boundary to avoid mis-resolving unrelated paths.
How can I resolve this? If you propose a fix, please make it concise.bfc1ccb to
f92900f
Compare
|
This pull request has been automatically marked as stale due to inactivity. |
|
This pull request has been automatically marked as stale due to inactivity. |
|
Closing due to inactivity. |
Greptile Overview
Greptile Summary
This PR adds a sandbox path resolver to translate container paths (e.g.
/workspace/...) into host workspace paths, and wires it intorunMessageActionso outbound actions can accept sandbox-style file parameters (filePath,path,media). It also exports the new resolver utilities via the plugin SDK and adds unit tests for the resolver behavior.Confidence Score: 3/5
SandboxWorkspaceInfoshape (will not typecheck) and the resolver’sstartsWithcheck will incorrectly rewrite paths that share a prefix with the container workdir (e.g./workspace2/...).(2/5) Greptile learns from your feedback when you react with thumbs up/down!