{"record":{"id":"b3ff80577f282603","repo":"denoland/deno","slug":"invalid-file-path-b3ff80","errorCode":null,"errorMessage":"Invalid file path '{}'","messagePattern":"Invalid file path '(.+?)'","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"cli/util/fs.rs","lineNumber":179,"sourceCode":"/// Gets the total size (in bytes) of a directory.\npub fn dir_size(path: &Path) -> std::io::Result<u64> {\n  let entries = std::fs::read_dir(path)?;\n  let mut total = 0;\n  for entry in entries {\n    let entry = entry?;\n    total += match entry.metadata()? {\n      data if data.is_dir() => dir_size(&entry.path())?,\n      data => data.len(),\n    };\n  }\n  Ok(total)\n}\n\npub fn specifier_from_file_path(\n  path: &Path,\n) -> Result<ModuleSpecifier, AnyError> {\n  ModuleSpecifier::from_file_path(path)\n    .map_err(|_| anyhow!(\"Invalid file path '{}'\", path.display()))\n}\n\n#[derive(Default)]\npub struct FsCleaner {\n  pub files_removed: u64,\n  pub dirs_removed: u64,\n  pub bytes_removed: u64,\n  /// Paths that could not be removed, along with the error encountered. The\n  /// cleaner is best-effort: a single locked or read-only file (for example a\n  /// cache database held open by a running Deno process) should not abort the\n  /// entire clean, so failures are collected here and reported afterwards.\n  pub failed: Vec<(PathBuf, std::io::Error)>,\n  pub progress_guard: Option<UpdateGuard>,\n}\n\nimpl FsCleaner {\n  pub fn new(progress_guard: Option<UpdateGuard>) -> Self {\n    Self {","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/util/fs.rs#L161-L197","documentation":"specifier_from_file_path (cli/util/fs.rs:175-179) is a shared CLI helper that turns a filesystem path into a file:// ModuleSpecifier via Url::from_file_path, which accepts only absolute, well-formed paths. It backs collect_specifiers — file discovery for deno test/lint/doc (fs.rs:115) — and the linter's explicit file list (linter.rs:130). The error means one of those paths could not become a valid absolute file URL.","triggerScenarios":"Passing a path argument that is not usable as an absolute file URL: an empty path, a relative path that escaped cwd-joining, or OS-specific malformed paths (e.g. paths with characters Windows rejects).","commonSituations":"Scripted invocations feeding deno lint/test unfiltered glob output; a file created with a name containing stray control characters; arguments mangled by shell interpolation or CI matrix templating.","solutions":["Re-run with concrete, existing file paths (relative to cwd or absolute).","Inspect the path in the message for stray quotes, spaces glued to names, or empty strings from a variable expansion.","Filter your file list before invoking deno (exclude non-files / odd names) when driving it from scripts."],"exampleFix":"# before — glob leaked a malformed entry\n$ deno lint $(cat files.txt)\nerror: Invalid file path 'src/\"mod.ts'\n\n# after — validate each entry exists first\n$ deno lint $(while read -r f; do [ -f \"$f\" ] && printf '%s\\n' \"$f\"; done < files.txt)","handlingStrategy":"validation","validationCode":"// Filter a candidate list down to real, absolute-or-cwd-relative files\nconst files = list.map((p) => p.trim()).filter((p) => p.length > 0);\nfor (const f of files) {\n  const abs = new URL(f, import.meta.resolve(\"./\")).pathname; // fails loudly on junk\n  if (!Deno.statSync(abs).isFile) throw new Error(`not a file: ${f}`);\n}","typeGuard":"const isUsablePath = (p: string) =>\n  p.length > 0 && !/[\\u0000]/.test(p) && !p.endsWith(\"/\") && !p.endsWith(\"..\");","tryCatchPattern":null,"preventionTips":["Validate glob/script output before feeding it to deno lint/test as file arguments.","Quote path arguments in shell to keep stray characters from gluing onto names.","Prefer letting Deno expand directories/globs itself over pre-building file lists in scripts."],"tags":["fs","path","specifier","cli"],"backgroundTag":"invalid-file-path","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}