Mintplex-Labs/anything-llm · error · Error
Input file ${inputPath} does not exist.
Error message
Input file ${inputPath} does not exist. What it means
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.
Source
Thrown at collector/utils/WhisperProviders/ffmpeg/index.js:83
execSync(`"${pathToTest}" -version`, { encoding: "utf8", stdio: "pipe" });
return true;
} catch {
return false;
}
}
/**
* Converts audio file to WAV format with required parameters for Whisper.
* Output: 16k hz, mono, 32bit float.
*
* @param {string} inputPath - Input path for audio file (any format supported by ffmpeg)
* @param {string} outputPath - Output path for converted file
* @returns {Promise<boolean>}
* @throws {Error} If ffmpeg binary cannot be found or conversion fails
*/
async convertAudioToWav(inputPath, outputPath) {
if (!fs.existsSync(inputPath))
throw new Error(`Input file ${inputPath} does not exist.`);
const outputDir = path.dirname(outputPath);
if (!fs.existsSync(outputDir)) fs.mkdirSync(outputDir, { recursive: true });
this.log(`Converting ${path.basename(inputPath)} to WAV format...`);
// Convert to 16k hz mono 32f
const result = spawnSync(
await this.ffmpegPath(),
[
"-i",
inputPath,
"-ar",
"16000",
"-ac",
"1",
"-acodec",
"pcm_f32le",
"-y",
outputPath,View on GitHub (pinned to 526360e320)
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.
Example fix
// before
async convertAudioToWav(inputPath, outputPath) {
if (!fs.existsSync(inputPath))
throw new Error(`Input file ${inputPath} does not exist.`);
// after — caller pre-validates with statSync (handles broken symlinks too)
const inputPath = path.resolve(tmpDir, filename);
if (!fs.statSync(inputPath).isFile()) throw new Error(`Missing source: ${inputPath}`);
await ffmpeg.convertAudioToWav(inputPath, outputPath); Defensive patterns
Strategy: validation
Validate before calling
const fs = require("fs");
function inputReady(p) {
try { return fs.statSync(p).isFile(); } catch { return false; }
}
// if (!inputReady(inputPath)) skip / report; Try / catch
try { await ffmpeg.convertAudioToWav(inPath, outPath); }
catch (e) {
if (e.message.startsWith("Input file") && e.message.includes("does not exist")) {
/* report missing source, skip */
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Temp file already cleaned by another worker; path typo; file on a different mount/container; relative path mis-resolved.
Related errors
- FFMPEG candidate path is not valid ffmpeg binary.
- No base URL was set.
- FFMPEG candidate path not found.
- FFMPEG binary not found.
- FFMPEG conversion failed
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/be4f10f8471d7b3b.
Report an issue: GitHub.