{"record":{"id":"977655099c997b66","repo":"GitoxideLabs/gitoxide","slug":"path-does-not-exist","errorCode":null,"errorMessage":"{path:?} does not exist.","messagePattern":"(.+?) does not exist\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-sec/src/identity.rs","lineNumber":170,"sourceCode":"            }\n            Ok(info.assume_init())\n        }\n    }\n\n    pub fn is_path_owned_by_current_user(path: &Path) -> io::Result<bool> {\n        use windows_sys::Win32::{\n            Foundation::{ERROR_INVALID_FUNCTION, ERROR_SUCCESS, LocalFree},\n            Security::{\n                Authorization::{GetNamedSecurityInfoW, SE_FILE_OBJECT},\n                CheckTokenMembership, EqualSid, IsWellKnownSid, OWNER_SECURITY_INFORMATION, PSECURITY_DESCRIPTOR,\n                TOKEN_ELEVATION_TYPE, TOKEN_LINKED_TOKEN, TOKEN_QUERY, TOKEN_USER, TokenElevationType,\n                TokenElevationTypeLimited, TokenLinkedToken, TokenUser, WinBuiltinAdministratorsSid,\n            },\n            System::Threading::{GetCurrentProcess, GetCurrentThread, OpenProcessToken, OpenThreadToken},\n        };\n\n        if !path.exists() {\n            return Err(io::Error::new(\n                io::ErrorKind::NotFound,\n                format!(\"{path:?} does not exist.\"),\n            ));\n        }\n\n        // Home is not actually owned by the corresponding user\n        // but it can be considered de-facto owned by the user\n        // Ignore errors here and just do the regular checks below\n        if gix_path::realpath(path).ok() == gix_path::env::home_dir() {\n            return Ok(true);\n        }\n\n        #[expect(unsafe_code)]\n        unsafe {\n            let (folder_owner, descriptor) = {\n                let mut folder_owner = MaybeUninit::uninit();\n                let mut pdescriptor = MaybeUninit::uninit();\n                let result = GetNamedSecurityInfoW(","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-sec/src/identity.rs#L152-L188","documentation":"`is_path_owned_by_current_user` first requires the path to exist; on Windows (and generally) if `path.exists()` is false it returns an io::Error of kind NotFound: \"{path:?} does not exist.\". The ownership check is undefined for non-existent files, so it fails fast instead of guessing.","triggerScenarios":"Calling `gix_sec::trust::is_path_owned_by_current_user(path)` (or higher-level trust checks in gix that call it) with a path that has been deleted, renamed, or was never created.","commonSituations":"Config file or hook path deleted between discovery and ownership check; typo'd path passed directly; race where another process removes the file; running against a template path not yet materialized.","solutions":["Verify the path exists before calling (std::path::Path::exists or create the file first)","Check the path spelling and that the file wasn't removed concurrently","Re-create the missing config/hook file, or point the check at an existing path","If the path is optional, handle NotFound gracefully instead of treating it as a trust failure"],"exampleFix":"// before\nlet owned = gix_sec::trust::is_path_owned_by_current_user(&cfg_path)?;\n\n// after\nif cfg_path.exists() {\n    let owned = gix_sec::trust::is_path_owned_by_current_user(&cfg_path)?;\n} else {\n    // treat as absent config, skip trust check\n}","handlingStrategy":"validation","validationCode":"if !path.as_ref().exists() {\n    return Err(anyhow::anyhow!(\"skipping trust check: {:?} missing\", path));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always check existence before ownership checks","Handle files deleted between discovery and check (TOCTOU)","Re-create default config files rather than checking trust of missing paths"],"tags":["path","not-found","ownership","security"],"backgroundTag":"file-not-found","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}