{"record":{"id":"be4f10f8471d7b3b","repo":"Mintplex-Labs/anything-llm","slug":"input-file-inputpath-does-not-exist","errorCode":null,"errorMessage":"Input file ${inputPath} does not exist.","messagePattern":"Input file (.+?) does not exist\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"collector/utils/WhisperProviders/ffmpeg/index.js","lineNumber":83,"sourceCode":"      execSync(`\"${pathToTest}\" -version`, { encoding: \"utf8\", stdio: \"pipe\" });\n      return true;\n    } catch {\n      return false;\n    }\n  }\n\n  /**\n   * Converts audio file to WAV format with required parameters for Whisper.\n   * Output: 16k hz, mono, 32bit float.\n   *\n   * @param {string} inputPath - Input path for audio file (any format supported by ffmpeg)\n   * @param {string} outputPath - Output path for converted file\n   * @returns {Promise<boolean>}\n   * @throws {Error} If ffmpeg binary cannot be found or conversion fails\n   */\n  async convertAudioToWav(inputPath, outputPath) {\n    if (!fs.existsSync(inputPath))\n      throw new Error(`Input file ${inputPath} does not exist.`);\n    const outputDir = path.dirname(outputPath);\n    if (!fs.existsSync(outputDir)) fs.mkdirSync(outputDir, { recursive: true });\n\n    this.log(`Converting ${path.basename(inputPath)} to WAV format...`);\n    // Convert to 16k hz mono 32f\n    const result = spawnSync(\n      await this.ffmpegPath(),\n      [\n        \"-i\",\n        inputPath,\n        \"-ar\",\n        \"16000\",\n        \"-ac\",\n        \"1\",\n        \"-acodec\",\n        \"pcm_f32le\",\n        \"-y\",\n        outputPath,","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/collector/utils/WhisperProviders/ffmpeg/index.js#L65-L101","documentation":"convertAudioToWav checks fs.existsSync(inputPath) before invoking ffmpeg and throws if the file is missing, guarding ffmpeg from receiving a nonexistent input. The message interpolates the offending path.","triggerScenarios":"Caller passes a path where fs.existsSync returns false — deleted file, wrong path, relative path resolved against the wrong cwd, or a race where the file was removed between queuing and processing.","commonSituations":"Temp file already cleaned by another worker; path typo; file on a different mount/container; relative path mis-resolved.","solutions":["Resolve the path to an absolute form and verify existence with fs.statSync before calling convertAudioToWav.","Eliminate races where another process deletes the temp file.","Confirm the file lives under the intended base directory."],"exampleFix":"// before\nasync convertAudioToWav(inputPath, outputPath) {\n  if (!fs.existsSync(inputPath))\n    throw new Error(`Input file ${inputPath} does not exist.`);\n\n// after — caller pre-validates with statSync (handles broken symlinks too)\nconst inputPath = path.resolve(tmpDir, filename);\nif (!fs.statSync(inputPath).isFile()) throw new Error(`Missing source: ${inputPath}`);\nawait ffmpeg.convertAudioToWav(inputPath, outputPath);","handlingStrategy":"validation","validationCode":"const fs = require(\"fs\");\nfunction inputReady(p) {\n  try { return fs.statSync(p).isFile(); } catch { return false; }\n}\n// if (!inputReady(inputPath)) skip / report;","typeGuard":null,"tryCatchPattern":"try { await ffmpeg.convertAudioToWav(inPath, outPath); }\ncatch (e) {\n  if (e.message.startsWith(\"Input file\") && e.message.includes(\"does not exist\")) {\n    /* report missing source, skip */\n  }\n  throw e;\n}","preventionTips":["Resolve file paths to absolute before handing to ffmpeg.","Use fs.statSync to verify existence (handles broken symlinks better than existsSync).","Avoid sharing temp directories between competing cleaners."],"tags":["ffmpeg","audio","filesystem","validation"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}