{"record":{"id":"7ed50222c37e9ecb","repo":"openai/codex","slug":"path-path-escapes-the-repository-root","errorCode":null,"errorMessage":"path {path:?} escapes the repository root","messagePattern":"path (.+?) escapes the repository root","errorType":"exception","errorClass":"GitToolingError","httpStatus":null,"severity":"error","filePath":"codex-rs/git-utils/src/errors.rs","lineNumber":27,"sourceCode":"#[derive(Debug, Error)]\npub enum GitToolingError {\n    #[error(\"git command `{command}` failed with status {status}: {stderr}\")]\n    GitCommand {\n        command: String,\n        status: ExitStatus,\n        stderr: String,\n    },\n    #[error(\"git command `{command}` produced non-UTF-8 output\")]\n    GitOutputUtf8 {\n        command: String,\n        #[source]\n        source: FromUtf8Error,\n    },\n    #[error(\"{path:?} is not a git repository\")]\n    NotAGitRepository { path: PathBuf },\n    #[error(\"path {path:?} must be relative to the repository root\")]\n    NonRelativePath { path: PathBuf },\n    #[error(\"path {path:?} escapes the repository root\")]\n    PathEscapesRepository { path: PathBuf },\n    #[error(\"failed to process path inside worktree\")]\n    PathPrefix(#[from] std::path::StripPrefixError),\n    #[error(transparent)]\n    Walkdir(#[from] WalkdirError),\n    #[error(transparent)]\n    Io(#[from] std::io::Error),\n}\n","sourceCodeStart":9,"sourceCodeEnd":36,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/git-utils/src/errors.rs#L9-L36","documentation":"GitToolingError variant for path escapes: a path joined against the worktree root resolves outside the repository root (via .. or symlink tricks). Snapshot restore refuses such paths to prevent writing outside the worktree.","triggerScenarios":"Thrown at codex-rs/git-utils/src/errors.rs:27 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Normalize the path lexically and reject any .. components that escape the root","Join with the repo root, canonicalize, and verify the result stays under the root before proceeding","Fix the caller to pass paths genuinely contained in the repository"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}