Skip to content

fix:sandbox file path Inconsistency - #14810

Closed
luckylhb90 wants to merge 2 commits into
openclaw:mainfrom
luckylhb90:fix/sandbox-path-Inconsistency
Closed

luckylhb90 wants to merge 2 commits into
openclaw:mainfrom
luckylhb90:fix/sandbox-path-Inconsistency

Conversation

@luckylhb90

@luckylhb90 luckylhb90 commented Feb 12, 2026 •

Copy link
Copy Markdown

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 into runMessageAction so 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

  • This PR is close, but has at least one definite TypeScript test failure and a concrete path-resolution logic bug that can mis-rewrite certain absolute paths.
  • Core change is small and localized, but the new test file uses an invalid SandboxWorkspaceInfo shape (will not typecheck) and the resolver’s startsWith check will incorrectly rewrite paths that share a prefix with the container workdir (e.g. /workspace2/...).
  • src/infra/outbound/sandbox-path-resolver.ts, src/infra/outbound/sandbox-path-resolver.test.ts

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +9 to +14
describe("resolveSandboxFilePath", () => {
const mockSandboxWorkspace: SandboxWorkspaceInfo = {
workspaceDir: "/opt/openclaw/sandboxes/agent-test-123",
containerWorkdir: "/workspace",
workspaceAccess: "rw",
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +25 to +29
// 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);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added stale Marked as stale due to inactivity and removed stale Marked as stale due to inactivity labels Feb 21, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Mar 12, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #pr-thunderdome-dangerzone on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: M stale Marked as stale due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant