{"record":{"id":"8e67f1a4419545ac","repo":"remotion-dev/remotion","slug":"model-model-already-exists-at-filepath-but","errorCode":null,"errorMessage":"Model ${model} already exists at ${filePath}, but the size is ${size} bytes (expected ${modelSizes[model]} bytes). Delete ${filePath} and try again.","messagePattern":"Model (.+?) already exists at (.+?), but the size is (.+?) bytes \\(expected (.+?) bytes\\)\\. Delete (.+?) and try again\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/install-whisper-cpp/src/download-whisper-model.ts","lineNumber":76,"sourceCode":"\t\tthrow new Error(\n\t\t\t`Invalid whisper model ${model}. Available: ${models.join(', ')}`,\n\t\t);\n\t}\n\n\tconst filePath = getModelPath(folder, model);\n\n\tif (existsSync(filePath)) {\n\t\tconst {size} = fs.statSync(filePath);\n\t\tif (size === modelSizes[model]) {\n\t\t\tif (printOutput) {\n\t\t\t\tconsole.log(`Model already exists at ${filePath}`);\n\t\t\t}\n\n\t\t\treturn Promise.resolve({alreadyExisted: true});\n\t\t}\n\n\t\tif (printOutput) {\n\t\t\tthrow new Error(\n\t\t\t\t`Model ${model} already exists at ${filePath}, but the size is ${size} bytes (expected ${modelSizes[model]} bytes). Delete ${filePath} and try again.`,\n\t\t\t);\n\t\t}\n\n\t\treturn Promise.resolve({alreadyExisted: false});\n\t}\n\n\tconst baseModelUrl = `https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-${model}.bin`;\n\tif (printOutput) {\n\t\tconsole.log(`Downloading whisper model ${model} from ${baseModelUrl}`);\n\t}\n\n\tconst fileStream = fs.createWriteStream(filePath);\n\n\tawait downloadFile({\n\t\tfileStream,\n\t\turl: baseModelUrl,\n\t\tprintOutput,","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/install-whisper-cpp/src/download-whisper-model.ts#L58-L94","documentation":"Thrown by `downloadWhisperModel` when a file already exists at the resolved model path but its byte size does not match the expected size from `modelSizes`. This indicates a corrupt or partial download (or a wrong file placed manually). Importantly, the throw only happens when `printOutput` is true (the default); with `printOutput: false` the function returns `{alreadyExisted: false}` and re-downloads instead.","triggerScenarios":"A previous download was interrupted, leaving a truncated `ggml-<model>.bin`; someone copied a different file to that path; disk corruption changed the file size. The size check `fs.statSync(filePath).size === modelSizes[model]` fails.","commonSituations":"CI cancelled mid-download leaving a partial file; running out of disk during download; switching model versions but reusing the same folder; manual file management.","solutions":["Delete the file at the path shown in the message and re-run `downloadWhisperModel`.","If you call it programmatically in a pipeline, pass `printOutput: false` so a size mismatch triggers an automatic re-download instead of throwing.","Ensure stable network and sufficient disk space before re-downloading large models (some are ~3GB)."],"exampleFix":"// before\ndownloadWhisperModel({model: 'large-v3', folder: 'whisper'});\n\n// after (auto-recover from partial downloads)\ndownloadWhisperModel({\n  model: 'large-v3',\n  folder: 'whisper',\n  printOutput: false,\n});","handlingStrategy":"validation","validationCode":"import fs from 'fs';\n\nfunction modelFileIsValid(folder: string, model: string, expectedSize: number): boolean {\n  const p = `${folder}/ggml-${model}.bin`;\n  return fs.existsSync(p) && fs.statSync(p).size === expectedSize;\n}\n\nif (!modelFileIsValid(folder, model, modelSizes[model])) {\n  fs.rmSync(`${folder}/ggml-${model}.bin`, {force: true});\n}","typeGuard":null,"tryCatchPattern":"try {\n  await downloadWhisperModel({model, folder});\n} catch (err) {\n  if (/size is .* bytes \\(expected/.test(String(err))) {\n    fs.rmSync(`${folder}/ggml-${model}.bin`, {force: true});\n    return downloadWhisperModel({model, folder}); // retry once after cleanup\n  }\n  throw err;\n}","preventionTips":["In CI, start from a clean cache or verify file size before reusing a downloaded model.","Pass printOutput: false in pipelines so partial files auto-trigger a re-download.","Ensure downloads are not interrupted (stable network, enough disk for ~3GB models)."],"tags":["whisper","filesystem","download","corruption"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}