{"record":{"id":"6fe4e3202b613176","repo":"seanmonstar/warp","slug":"file-open-error","errorCode":null,"errorMessage":"file_open_error","messagePattern":"file_open_error","errorType":"http","errorClass":"FileOpenError","httpStatus":500,"severity":"error","filePath":"src/filters/fs.rs","lineNumber":289,"sourceCode":"            let rej = match err.kind() {\n                io::ErrorKind::NotFound => {\n                    tracing::debug!(\"file not found: {:?}\", path.as_ref().display());\n                    reject::not_found()\n                }\n                io::ErrorKind::PermissionDenied => {\n                    tracing::warn!(\"file permission denied: {:?}\", path.as_ref().display());\n                    reject::known(FilePermissionError { _p: () })\n                }\n                _ => {\n                    tracing::error!(\n                        \"file open error (path={:?}): {} \",\n                        path.as_ref().display(),\n                        err\n                    );\n                    reject::known(FileOpenError { _p: () })\n                }\n            };\n            Either::Right(future::err(rej))\n        }\n    })\n}\n\nasync fn file_metadata(f: TkFile) -> Result<(TkFile, Metadata), Rejection> {\n    match f.metadata().await {\n        Ok(meta) => Ok((f, meta)),\n        Err(err) => {\n            tracing::debug!(\"file metadata error: {}\", err);\n            Err(reject::not_found())\n        }\n    }\n}\n\nfn file_conditional(\n    f: TkFile,\n    path: ArcPath,\n    conditionals: Conditionals,","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/seanmonstar/warp/blob/ff34d7213ed55ec342304aa7ff6ac4b351da9e66/src/filters/fs.rs#L271-L307","documentation":"FileOpenError is the rejection returned by warp::fs::file / file_reply (src/filters/fs.rs) when std::fs::File::open on the requested path fails. The path was resolved but could not be opened, most commonly because it does not exist or the process lacks read permission. The error is logged (the underlying io::Error is printed) and a generic file_open_error rejection is returned so internals are not leaked.","triggerScenarios":"warp::fs::file(\"path\") or fs::file_reply used with a path that does not exist, is a directory opened as a file, has a broken symlink, or is unreadable by the server process (permission denied).","commonSituations":"Relative path resolved against an unexpected working directory; serving static assets where the build output folder wasn't deployed; file deleted between route match and open; Docker container missing the mounted file; running the server as a user without read access to the asset directory.","solutions":["Verify the file exists at the exact path (use an absolute path in warp::fs::file)","Check the file's permissions and the user the server process runs as","Confirm relative paths resolve from the process working directory, not the crate root","If serving a directory, use warp::fs::dir instead of fs::file","Check the server log next to this rejection: the real io::Error is printed there"],"exampleFix":"// before\nlet route = warp::path(\"report\").and(warp::fs::file(\"out/report.pdf\"));\n// after\nlet route = warp::path(\"report\")\n    .and(warp::fs::file(\"/var/www/assets/report.pdf\"));","handlingStrategy":"validation","validationCode":"// check before serving\nlet path = std::path::Path::new(\"/var/www/assets/report.pdf\");\nif !path.is_file() {\n    eprintln!(\"missing or not a file: {}\", path.display());\n}\nmatch std::fs::File::open(path) {\n    Ok(_) => (),\n    Err(e) => eprintln!(\"cannot open {}: {}\", path.display(), e),\n}","typeGuard":"fn is_readable_file(p: &str) -> bool {\n    std::fs::File::open(p).is_ok()\n}","tryCatchPattern":"let route = warp::path(\"report\")\n    .and(warp::fs::file(\"/var/www/assets/report.pdf\"))\n    .recover(|rej: warp::Rejection| async move {\n        if rej.find::<warp::reject::FileOpenError>().is_some() {\n            Ok(warp::reply::with_status(\"file unavailable\", warp::http::StatusCode::NOT_FOUND))\n        } else {\n            Err(rej)\n        }\n    });","preventionTips":["Use absolute paths for static assets","Verify the file exists in your deploy/CI step before the server starts","Mount volumes correctly in containers and check read permissions for the runtime user","Prefer warp::fs::dir for directory-based serving","Log the working directory at startup if using relative paths"],"tags":["filesystem","io","warp","static-files"],"backgroundTag":"file-open-failed","analyzedSha":"ff34d7213ed55ec342304aa7ff6ac4b351da9e66","analyzedAt":"2026-09-09T16:57:46.316Z","contentChangedAt":"2026-09-09T16:57:46.316Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}