{"record":{"id":"ecf7e469a789ecb4","repo":"pola-rs/polars","slug":"source-path","errorCode":null,"errorMessage":"{source}: {path}","messagePattern":"\\{source\\}: \\{path\\}","errorType":"error_code","errorClass":"PathIoError","httpStatus":null,"severity":"error","filePath":"crates/polars-utils/src/io.rs","lineNumber":52,"sourceCode":"                self.source\n            )\n        } else {\n            write!(f, \"{}: {path}\", self.source)\n        }\n    }\n}\n\nimpl std::error::Error for PathIoError {\n    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {\n        Some(&self.source)\n    }\n}\n\n/// Attaches `path` to `err`, keeping its [`io::ErrorKind`].\n///\n/// The path is available in full through [`PathIoError`], and truncated in the message.\npub fn _limit_path_len_io_err(path: &Path, err: io::Error) -> PolarsError {\n    io::Error::new(\n        err.kind(),\n        PathIoError {\n            path: path.to_path_buf(),\n            source: err,\n        },\n    )\n    .into()\n}\n\npub fn open_file(path: &Path) -> PolarsResult<File> {\n    File::open(path).map_err(|err| _limit_path_len_io_err(path, err))\n}\n\npub fn open_file_write(path: &Path) -> PolarsResult<File> {\n    std::fs::OpenOptions::new()\n        .write(true)\n        .create(true)\n        .truncate(true)","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-utils/src/io.rs#L34-L70","documentation":"Polars wraps I/O errors with the offending file path via _limit_path_len_io_err, producing a PolarsError whose message is formatted as '{source}: {path}'. The original io::ErrorKind is preserved and the full path is available in the PathIoError payload; the path may be truncated in the display message if very long. This wrapper is applied by path-based operations such as opening files, memory-mapping, mkdir_recursive, and cloud path expansion.","triggerScenarios":"Any failing filesystem or cloud-storage operation on a path: scan_csv/scan_parquet/read_ipc with a nonexistent file, permission-denied paths, failed mkdir chains, or invalid cloud URLs expanded via expand_path_cloud.","commonSituations":"Typos in file paths; files moved/deleted between check and read; missing cloud credentials surfacing as path errors; permission-restricted directories; relative paths resolved from an unexpected working directory.","solutions":["Check the path in the message: verify the file/directory exists (Path::exists) and the path is spelled correctly","Verify read/write permissions on the path and its parent directories","For cloud paths, verify the URL scheme, bucket, and credentials configuration","Match on the PolarsError/PathIoError payload to recover the full untruncated path programmatically"],"exampleFix":"// before\nlet df = pl.scan_parquet(\"data/fiel.parquet\").collect()?; // typo\n// after\nlet path = std::path::Path::new(\"data/file.parquet\");\nassert!(path.exists(), \"missing input: {}\", path.display());\nlet df = pl.scan_parquet(path).collect()?;","handlingStrategy":"try-catch","validationCode":"// Rust: verify path accessibility before reading\nlet path = std::path::Path::new(\"data/file.parquet\");\nassert!(path.exists(), \"path does not exist: {}\", path.display());\nassert!(path.is_file(), \"path is not a file: {}\", path.display());\nstd::fs::File::open(path).expect(\"path not readable\");","typeGuard":"fn readable_file(p: &std::path::Path) -> bool { p.is_file() && std::fs::File::open(p).is_ok() }","tryCatchPattern":"match lf.collect() {\n    Err(PolarsError::IO(err)) if err.kind() == io::ErrorKind::NotFound => { /* log full path, prompt user */ },\n    other => other?,\n}","preventionTips":["Check file existence and permissions before launching scans","Use absolute paths or a known working directory","For cloud paths, pre-validate scheme/bucket and credentials","Extract the full path from PathIoError when display is truncated"],"tags":["rust","io","filesystem","error-wrapping"],"backgroundTag":"file-not-found","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}