{"record":{"id":"fad3bd215f4cdb24","repo":"openai/codex","slug":"local-cwd-uri-cwd-display-is-not-a-host-native","errorCode":null,"errorMessage":"local cwd URI `{cwd_display}` is not a host-native path","messagePattern":"local cwd URI `(.+?)` is not a host-native path","errorType":"validation","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/core/src/tools/approvals.rs","lineNumber":358,"sourceCode":"                permissions,\n            } => crate::guardian::GuardianApprovalRequest::RequestPermissions {\n                id,\n                turn_id,\n                reason,\n                permissions,\n            },\n        })\n    }\n}\n\nfn guardian_cwd(environment_id: &str, cwd: PathUri) -> std::io::Result<AbsolutePathBuf> {\n    match cwd.to_abs_path() {\n        Ok(cwd) => Ok(cwd),\n        Err(err) if environment_id != codex_exec_server::LOCAL_ENVIRONMENT_ID => Err(err),\n        Err(_) => {\n            let cwd_display = cwd.to_string();\n            let path = cwd.to_url().to_file_path().map_err(|()| {\n                std::io::Error::new(\n                    std::io::ErrorKind::InvalidInput,\n                    format!(\"local cwd URI `{cwd_display}` is not a host-native path\"),\n                )\n            })?;\n            AbsolutePathBuf::from_absolute_path_checked(path).map_err(|err| {\n                std::io::Error::new(\n                    std::io::ErrorKind::InvalidInput,\n                    format!(\"local cwd URI `{cwd_display}` is not absolute: {err}\"),\n                )\n            })\n        }\n    }\n}\n\n#[derive(Clone, Copy, Debug, PartialEq, Eq)]\nenum ApprovalReviewer {\n    Guardian,\n    User,","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/core/src/tools/approvals.rs#L340-L376","documentation":"guardian_cwd converts a session cwd PathUri to an AbsolutePathBuf for approval requests (ExecCommand, ApplyPatch). It first tries PathUri::to_abs_path(); for the LOCAL environment only, a failure falls back to URL→filesystem-path conversion via to_url().to_file_path(). This io::Error(InvalidInput) fires when that conversion is impossible — the URI is not a convertible file URL on this host, e.g. a non-file scheme or a file URL carrying a host authority (file://host/share) that has no meaning as a host-native path.","triggerScenarios":"An approval request on the local environment whose cwd PathUri is a remote/virtual-scheme URI (vscode-remote://, https://) or a file URL with an authority component, so to_file_path() returns Err(()).","commonSituations":"IDE/app-server integrations passing editor workspace URIs verbatim as cwd; remote-development workspaces incorrectly marked local; URI rewriting bugs that preserve scheme/authority where a plain file:///path was expected.","solutions":["Pass cwd as a plain absolute file URI (file:///abs/path, empty authority) from the client/app-server side","Verify the session is not marked LOCAL when the cwd actually belongs to a remote environment — non-local environments fail earlier at to_abs_path and never hit this branch","Fix upstream URI construction: strip scheme/authority and rebuild a file URL from the absolute path","Upgrade the integration if a newer version normalizes workspace URIs before sending approval requests"],"exampleFix":"// before — editor workspace URI passed through\nrequest.cwd = PathUri::from(\"vscode-remote://ssh-remote%2Bbox/workspace/app\");\n// → local cwd URI `vscode-remote://ssh-remote%2Bbox/workspace/app` is not a host-native path\n\n// after — send the host-native file URI for local sessions\nrequest.cwd = PathUri::from(\"file:///home/user/workspace/app\");","handlingStrategy":"validation","validationCode":"// Before building an approval request for a LOCAL environment:\nfn local_cwd_ok(cwd: &PathUri) -> bool {\n    if cwd.to_abs_path().is_ok() { return true; }\n    let u = cwd.to_url();\n    u.scheme() == \"file\" && u.host_str().is_none() && u.to_file_path().is_ok()\n}","typeGuard":"fn is_native_file_uri(cwd: &PathUri) -> bool {\n    let u = cwd.to_url();\n    u.scheme() == \"file\" && u.host_str().is_none() && u.to_file_path().is_ok()\n}","tryCatchPattern":"match guardian_cwd(env_id, cwd.clone()) {\n    Err(e) if e.kind() == std::io::ErrorKind::InvalidInput => {\n        reject_request_with_retryable_hint(e); // ask client to resend absolute file URI\n    }\n    r => r?,\n}","preventionTips":["Always construct session cwd as file:/// with an empty authority and absolute path","Never forward editor workspace URIs (vscode-remote:// etc.) as cwd for local sessions","Add contract tests asserting local cwd URIs round-trip through to_file_path"],"tags":["rust","codex","approvals","cwd","file-uri","path-validation"],"backgroundTag":"invalid-file-uri","analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}