{"record":{"id":"138eca8d1ac3dd18","repo":"denoland/deno","slug":"invalid-file-path","errorCode":null,"errorMessage":"Invalid file path: {}","messagePattern":"Invalid file path: (.+?)","errorType":"validation","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/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/transpile.rs#L77-L113","documentation":"`deno transpile` converts each input path into a file:// ModuleSpecifier before parsing (cli/tools/transpile.rs:93-96). Url::from_file_path only accepts absolute, well-formed paths, so this guard fires when the cwd-joined path still cannot form a valid absolute file URL. It is a defensive check — ordinary relative or absolute .ts/.tsx inputs never trip it.","triggerScenarios":"A transpile argument that degenerates into a non-absolute or malformed path (empty argument, a path composed only of `..` segments resolving above a relative cwd, or OS-specific invalid path forms).","commonSituations":"Programmatic invocation of deno transpile with unvalidated file lists; scripts passing glob results that include odd entries; embedding the CLI with an unusual working directory.","solutions":["Pass a plain relative or absolute TypeScript path: deno transpile src/mod.ts.","Inspect the failing argument (shown in the message) for stray quotes, spaces, or empty strings leaking in from a script.","If it reproduces with a normal-looking path, capture the exact command line and report upstream — this branch should be unreachable for absolute paths."],"exampleFix":"# before — argument polluted by script interpolation\n$ deno transpile \"${SRC_DIR}/mod.ts\"   # SRC_DIR empty -> /mod.ts oddity or \"\"\nerror: Invalid file path: ...\n\n# after — validate before invoking\n$ test -n \"$SRC_DIR\" && deno transpile \"$SRC_DIR/mod.ts\"","handlingStrategy":"validation","validationCode":"# Sanity-check every argument is a non-empty, absolute-or-cwd-relative .ts/.tsx file\nfor f in \"$@\"; do\n  [ -n \"$f\" ] && [ -f \"$f\" ] || { echo \"skipping invalid path: '$f'\"; continue; }\ndone\ndeno transpile \"$@\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass concrete relative or absolute .ts/.tsx paths to deno transpile.","When driving the CLI from scripts, filter out empty and non-file entries from generated lists.","Echo the exact argument vector before invoking deno when debugging path errors."],"tags":["transpile","path","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"}