{"record":{"id":"138eca8d1ac3dd18","repo":"denoland/deno","slug":"invalid-file-path","errorCode":null,"errorMessage":"Invalid file path: {}","messagePattern":"Invalid file path: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"cli/tools/transpile.rs","lineNumber":95,"sourceCode":"\n  // Collect file paths and specifiers\n  let mut file_entries = Vec::new();\n  for file_path_str in files {\n    let file_path = cwd.join(file_path_str);\n\n    let media_type = MediaType::from_path(&file_path);\n    if !media_type.is_emittable() {\n      log::warn!(\n        \"{} Skipping {} (not a TypeScript/JSX/TSX file)\",\n        colors::yellow(\"Warning\"),\n        file_path.display()\n      );\n      continue;\n    }\n\n    let specifier =\n      ModuleSpecifier::from_file_path(&file_path).map_err(|_| {\n        anyhow::anyhow!(\"Invalid file path: {}\", file_path.display())\n      })?;\n\n    file_entries.push((file_path, specifier, media_type));\n  }\n\n  if file_entries.is_empty() {\n    anyhow::bail!(\n      \"No emittable files found. Only TypeScript/JSX/TSX files can be transpiled.\"\n    );\n  }\n\n  // Transpile each file (TS -> JS)\n  for (file_path, specifier, media_type) in &file_entries {\n    let source_bytes = sys\n      .fs_read(file_path)\n      .with_context(|| format!(\"Failed to read {}\", file_path.display()))?;\n    let source_code = String::from_utf8(source_bytes.into_owned())\n      .with_context(|| format!(\"{} is not valid UTF-8\", file_path.display()))?;","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/cli/tools/transpile.rs#L77-L113","documentation":"Each input path is converted to a `file://` ModuleSpecifier before transpiling. `ModuleSpecifier::from_file_path` fails for paths that cannot become a valid file URL — an empty path or bytes that are not valid UTF-8 — and that failure surfaces as this error with the printed path.","triggerScenarios":"A path argument that resolves to an empty string, or a filename containing non-UTF-8 bytes (e.g. from locale-mangled glob expansion or an unvalidated variable).","commonSituations":"Scripts that build paths from unvalidated environment variables; Unix filenames created with invalid encoding; empty-string expansion of `$FILE` reaching the CLI.","solutions":["Reproduce and inspect the argument (`printf '%s' \"$arg\" | od -c`) and fix or rename it to valid UTF-8","Quote and null-check variables in the calling script so empty values fail before deno runs","Add `set -u` (or equivalent) to catch unset variables in wrapper scripts"],"exampleFix":"# before\ndeno transpile \"$MAYBE_EMPTY\"\n# after\n[ -n \"$MAYBE_EMPTY\" ] && deno transpile \"$MAYBE_EMPTY\"","handlingStrategy":"validation","validationCode":"# bash: reject empty and non-UTF-8 args up front\nfor f in \"$@\"; do\n  [ -n \"$f\" ] || { echo \"empty path argument\" >&2; exit 1; }\n  printf '%s' \"$f\" | LC_ALL=C grep -qP '[\\x80-\\xFF]' && { echo \"non-UTF-8 path: $f\" >&2; exit 1; }\ndone\ndeno transpile \"$@\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Null-check every path variable before passing it to the CLI","Avoid building filenames from raw byte data; normalize to UTF-8 first","Run `locale` in build containers so glob expansion does not mangle filenames"],"tags":["cli","transpile","paths","encoding"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}