{"record":{"id":"f5f5538378de83c8","repo":"Hmbown/CodeWhale","slug":"not-a-regular-non-reparse-file","errorCode":null,"errorMessage":"not a regular non-reparse file","messagePattern":"not a regular non-reparse file","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_threads.rs","lineNumber":13856,"sourceCode":"    let metadata = file.metadata()?;\n    anyhow::ensure!(\n        metadata.is_file() && metadata.nlink() == 1,\n        \"not one regular file\"\n    );\n    Ok((metadata.dev(), metadata.ino()))\n}\n\n#[cfg(windows)]\nfn runtime_store_file_identity(file: &File) -> Result<(u64, u64)> {\n    use std::os::windows::fs::MetadataExt as _;\n    use std::os::windows::io::AsRawHandle as _;\n    use windows_sys::Win32::Storage::FileSystem::{\n        BY_HANDLE_FILE_INFORMATION, FILE_ATTRIBUTE_REPARSE_POINT, GetFileInformationByHandle,\n    };\n\n    let metadata = file.metadata()?;\n    let safe = metadata.is_file() && metadata.file_attributes() & FILE_ATTRIBUTE_REPARSE_POINT == 0;\n    anyhow::ensure!(safe, \"not a regular non-reparse file\");\n    let mut info = BY_HANDLE_FILE_INFORMATION::default();\n    // SAFETY: the handle and writable output remain valid for the call.\n    if unsafe { GetFileInformationByHandle(file.as_raw_handle(), &mut info) } == 0 {\n        return Err(std::io::Error::last_os_error()).context(\"Inspect Runtime store file identity\");\n    }\n    anyhow::ensure!(info.nNumberOfLinks == 1, \"has multiple filesystem links\");\n    Ok((\n        u64::from(info.dwVolumeSerialNumber),\n        (u64::from(info.nFileIndexHigh) << 32) | u64::from(info.nFileIndexLow),\n    ))\n}\n\n#[cfg(all(not(unix), not(windows)))]\nfn runtime_store_file_identity(file: &File) -> Result<(u64, u64)> {\n    anyhow::ensure!(file.metadata()?.is_file(), \"must be a regular file\");\n    Ok((0, 0))\n}\n","sourceCodeStart":13838,"sourceCodeEnd":13874,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/runtime_threads.rs#L13838-L13874","documentation":"On Windows, `runtime_store_file_identity` reads a file's metadata and rejects anything that is not a regular file or that carries the FILE_ATTRIBUTE_REPARSE_POINT attribute (symlinks, junctions, mount points). Identity tracking requires a plain physical file, and reparse points can redirect to arbitrary targets, so the function refuses them. The ensure! fires before the Win32 GetFileInformationByHandle call when either condition holds.","triggerScenarios":"Passing a `File` handle to a path that is a directory, or to a symlink/junction/reparse point (OneDrive placeholder, Dev Drive mount, WSL symlink), or a file with metadata.file_attributes() & FILE_ATTRIBUTE_REPARSE_POINT != 0.","commonSituations":"Runtime store configured under a OneDrive-synced or junctioned directory on Windows; path given via a symbolic link; the configured path is actually a directory.","solutions":["Resolve the path to its real target before opening (`std::fs::canonicalize`) and ensure it is a regular file without reparse attributes","Move the runtime store out of synced/junctioned directories (OneDrive, Documents redirected) into a plain local path","Verify the configured store path is not a directory or junction"],"exampleFix":"// before\nlet f = File::open(&cfg.runtime_store_path)?; // path is a junction\nlet id = runtime_store_file_identity(&f)?;\n// after\nlet real = std::fs::canonicalize(&cfg.runtime_store_path)?;\nlet meta = std::fs::metadata(&real)?;\nanyhow::ensure!(meta.is_file(), \"store must be a regular file\");\nlet f = File::open(&real)?;\nlet id = runtime_store_file_identity(&f)?;","handlingStrategy":"validation","validationCode":"let meta = std::fs::metadata(path)?;\nif !meta.is_file() {\n    return Err(anyhow!(\"{} is not a regular file\", path.display()));\n}","typeGuard":"fn is_plain_windows_file(f: &File) -> bool {\n    f.metadata().map(|m| m.is_file() && m.file_attributes() & 0x400 == 0).unwrap_or(false)\n} // 0x400 == FILE_ATTRIBUTE_REPARSE_POINT","tryCatchPattern":"match runtime_store_file_identity(&f) {\n    Ok(id) => id,\n    Err(e) => { eprintln!(\"store path must be a plain local file: {e:#}\"); std::process::exit(1); }\n}","preventionTips":["Keep the store outside OneDrive/junctioned/synced folders","Canonicalize paths before opening","Verify attributes with `fsutil reparsepoint query` if unsure"],"tags":["filesystem","windows","reparse-point"],"backgroundTag":"incompatible-source-type","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}