path-uri: clarify invalid host path errors (#28473)

## Why

Ensure a consistent string format when exposing path conversion errors
to the model.

## What

- Render `PathUriParseError::InvalidFileUriPath` as `'$PATH' is invalid
on '$OS'`.
This commit is contained in:
Adam Perry @ OpenAI
2026-06-16 09:03:44 -07:00
committed by GitHub
parent 40e7dda4d2
commit 7162030b37
3 changed files with 50 additions and 25 deletions
+7 -10
View File
@@ -154,11 +154,8 @@ fn sandbox_cwd(sandbox: &FileSystemSandboxContext) -> Result<SandboxCwd, JSONRPC
}
fn native_sandbox_cwd(cwd: &PathUri) -> Result<AbsolutePathBuf, JSONRPCErrorError> {
cwd.to_abs_path().map_err(|err| {
invalid_request(format!(
"file system sandbox cwd is not native to this exec-server host: {err}"
))
})
cwd.to_abs_path()
.map_err(|err| invalid_request(err.to_string()))
}
fn helper_read_roots(runtime_paths: &ExecServerRuntimePaths) -> Vec<AbsolutePathBuf> {
@@ -561,16 +558,16 @@ mod tests {
FileSystemSpecialPath::project_roots(/*subpath*/ None),
FileSystemAccessMode::Write,
)]);
let sandbox_context = sandbox_context_with_cwd(&policy, cwd);
let sandbox_context = sandbox_context_with_cwd(&policy, cwd.clone());
let err = sandbox_cwd(&sandbox_context).expect_err("non-native cwd should be rejected");
assert_eq!(
err,
crate::rpc::invalid_request(
"file system sandbox cwd is not native to this exec-server host: file URI contains an invalid absolute path"
.to_string()
)
crate::rpc::invalid_request(format!(
"'{cwd}' is invalid on '{}'",
std::env::consts::OS
))
);
}