{"record":{"id":"4f04878b19529b63","repo":"FyroxEngine/Fyrox","slug":"invalid-path","errorCode":null,"errorMessage":"Invalid path: {}","messagePattern":"Invalid path: (.+?)","errorType":"error_code","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"fyrox-core/src/lib.rs","lineNumber":313,"sourceCode":"#[inline]\npub fn hash_combine(lhs: u64, rhs: u64) -> u64 {\n    lhs ^ (rhs\n        .wrapping_add(0x9e3779b9)\n        .wrapping_add(lhs << 6)\n        .wrapping_add(lhs >> 2))\n}\n\n/// Strip working directory from file name. The function may fail for one main reason -\n/// input path is not valid, does not exist, or there is some other issues with it.\n/// The last component of the path is permitted to not exist, so long as the rest of the path exists.\npub fn make_relative_path<P: AsRef<Path>>(path: P) -> Result<PathBuf, std::io::Error> {\n    let path = path.as_ref();\n    if path.as_os_str() == \".\" {\n        return Ok(path.to_path_buf());\n    }\n    // Canonicalization requires the full path to exist, so remove the file name before\n    // calling canonicalize.\n    let file_name = path.file_name().ok_or(std::io::Error::new(\n        std::io::ErrorKind::InvalidData,\n        format!(\"Invalid path: {}\", path.display()),\n    ))?;\n    let dir = path.parent();\n    let dir = if let Some(dir) = dir {\n        if dir.as_os_str().is_empty() {\n            Path::new(\".\")\n        } else {\n            dir\n        }\n    } else {\n        Path::new(\".\")\n    };\n\n    let cwd = std::env::current_dir()?;\n\n    // Try without canonicalization first to preserve symlinks.\n    let non_canon_dir = if dir.is_absolute() {","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/FyroxEngine/Fyrox/blob/76c91aad8eca488ce527b1af707be8b3b24ad72d/fyrox-core/src/lib.rs#L295-L331","documentation":"make_relative_path converts an absolute path to one relative to the resource/working directory. It strips the file name before canonicalizing the parent directory (canonicalization requires the path to exist). If the input path has no file-name component (e.g. a bare directory root like \"/\" or \"..\" segments only), it cannot proceed and returns an InvalidData io::Error.","triggerScenarios":"Passing a path with no file name (\"/\", \"C:\\\\\", \".\\\\sub\\\\\" style paths ending in a separator, or \".\") other than the literal \".\" shortcut, to make_relative_path; called from relative_path, open, refresh, save_scene, load_scene, LightmapperSettings.","commonSituations":"Users pointing engine settings at a directory instead of a file; loading scenes via paths built by string concatenation that leave a trailing separator; drive/root paths on Windows or Unix.","solutions":["Pass a full path that includes the file name of an existing file","Normalize/canonicalize the path (strip trailing separators) before calling","Check path.file_name().is_some() before invoking and surface a friendly error"],"exampleFix":"// before\nengine.resource_manager.resource_path_abs(\"/\");\n\n// after\nlet abs = engine.resource_manager.resource_path_abs(\"data/scene.fbx\")?;","handlingStrategy":"validation","validationCode":"fn has_file_name(p: &Path) -> bool { p.file_name().is_some() }","typeGuard":"fn is_valid_resource_path(p: &Path) -> bool { !p.as_os_str().is_empty() && p.file_name().is_some() }","tryCatchPattern":"match make_relative_path(&p) { Ok(rel) => rel, Err(e) => eprintln!(\"bad path {}: {e}\", p.display()) }","preventionTips":["Always pass paths that point to an existing file, never a bare root or trailing-separator directory","Use Path::join instead of string concatenation to build paths","Handle the returned io::Error rather than unwrapping"],"tags":["path","io","invalid-path"],"backgroundTag":"invalid-argument-format","analyzedSha":"76c91aad8eca488ce527b1af707be8b3b24ad72d","analyzedAt":"2026-09-10T16:04:01.633Z","contentChangedAt":"2026-09-10T16:04:01.633Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}