openclaw/openclaw · error · Error

file URI is not valid for the sandbox

Error message

${label} file URI is not valid for the sandbox: ${error instanceof Error ? error.message : String(error)}

What it means

fileURLToPath threw while decoding the accepted file URI with POSIX rules — the URI is syntactically a URL but its percent-encoding or host component cannot resolve to a sandbox path; the decode error is attached as cause.

Solutions

  1. Percent-encode path segments correctly (e.g. %20 for spaces)
  2. Avoid percent-encoded NUL, slash, or dot-segment tricks that break decoding
  3. Inspect error.cause for the exact fileURLToPath failure
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at extensions/codex/src/app-server/sandbox-exec-server/path-uri.ts:31 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openclaw/openclaw@01804a7531 (2026-08-12). Data as JSON: /api/errors/acc15619e1a9f3c6. Report an issue: GitHub.

Appendix: source

Thrown at extensions/codex/src/app-server/sandbox-exec-server/path-uri.ts:31

      `${label} must be a valid file URI: ${error instanceof Error ? error.message : String(error)}`,
      { cause: error },
    );
  }
  if (pathUrl.protocol !== "file:") {
    throw new Error(
      `${label} URI must use the file scheme, received ${pathUrl.protocol.slice(0, -1)}.`,
    );
  }
  if (pathUrl.search || pathUrl.hash) {
    throw new Error(`${label} file URI must not include a query or fragment.`);
  }
  let resolved: string;
  try {
    // The URI names the sandbox target, so decode with POSIX rules even when
    // the Gateway host is Windows. Docker and SSH backends own POSIX workdirs.
    resolved = fileURLToPath(pathUrl, { windows: false });
  } catch (error) {
    throw new Error(
      `${label} file URI is not valid for the sandbox: ${error instanceof Error ? error.message : String(error)}`,
      { cause: error },
    );
  }
  if (WINDOWS_DRIVE_PATH_RE.test(resolved)) {
    // OpenClaw exec-server backends currently expose Docker/SSH POSIX paths.
    // Reject foreign drive URIs instead of silently rewriting their meaning.
    throw new Error(`${label} Windows file URI is not supported by the sandbox.`);
  }
  if (resolved.includes("\0")) {
    throw new Error(`${label} file URI must not contain a null byte.`);
  }
  return resolved;
}

View on GitHub (pinned to 01804a7531)