{"record":{"id":"26cc845ab0cae05f","repo":"janhq/jan","slug":"file-not-found-path","errorCode":null,"errorMessage":"File not found: ${path}","messagePattern":"File not found: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"extensions/llamacpp-extension/src/index.ts","lineNumber":3136,"sourceCode":"              ? opts.modelSha256\n              : saveName === 'mmproj.gguf'\n                ? opts.mmprojSha256\n                : undefined,\n          size:\n            saveName === 'model.gguf'\n              ? opts.modelSize\n              : saveName === 'mmproj.gguf'\n                ? opts.mmprojSize\n                : undefined,\n          model_id: modelId,\n        })\n        return localPath\n      }\n\n      // if local file (absolute path), check if it exists\n      // and return the path\n      if (!(await fs.existsSync(path)))\n        throw new Error(`File not found: ${path}`)\n      return path\n    }\n\n    let modelPath = await maybeDownload(opts.modelPath, 'model.gguf')\n    let mmprojPath = opts.mmprojPath\n      ? await maybeDownload(opts.mmprojPath, 'mmproj.gguf')\n      : undefined\n    // MTP draft companion (speculative decoding); paired with the main model.\n    let mtpModelPath = opts.mtpPath\n      ? await maybeDownload(opts.mtpPath, 'mtp.gguf')\n      : undefined\n\n    if (downloadItems.length > 0) {\n      try {\n        // emit download update event on progress\n        const onProgress = (transferred: number, total: number) => {\n          events.emit(DownloadEvent.onFileDownloadUpdate, {\n            modelId,","sourceCodeStart":3118,"sourceCodeEnd":3154,"githubUrl":"https://github.com/janhq/jan/blob/fad3f12a147d138388a66f0d92a02b2675f65294/extensions/llamacpp-extension/src/index.ts#L3118-L3154","documentation":"Thrown inside maybeDownload() (runImport's local-file branch) when opts.modelPath / opts.mmprojPath / opts.mtpPath is not an https URL and the file at that absolute local path does not exist on disk. maybeDownload routes https:// paths into the download queue and treats everything else as a local file - this guard verifies the local file is actually present before import proceeds to GGUF validation.","triggerScenarios":"Passing modelPath as a local path to a file that was moved, deleted, or never downloaded; passing a relative path when an absolute path is expected; pointing at the wrong drive/mount on Windows/Linux; the mmproj path was optional-looking but actually supplied and missing.","commonSituations":"User picked a model file in the file dialog then moved it before import finished. Path uses Windows backslashes or a different volume label than where the file lives. Network mount disconnected. Typo in the path. Symlink that points to a removed target.","solutions":["Verify the absolute path is correct and the file exists before calling import (run fs.existsSync yourself).","If the file moved, re-locate it and pass the updated path.","If the model is remote, pass an https:// URL instead of a local path so maybeDownload routes it to the downloader.","Normalize the path (resolve symlinks, convert relative to absolute) before passing it in."],"exampleFix":"// before\nawait provider.import('x', { modelPath: '/mnt/models/qwen.gguf' }) // throws - file moved\n// after\nconst p = '/mnt/models/qwen.gguf'\nif (!(await fs.existsSync(p))) throw new Error(`please re-pick the model file; not found at ${p}`)\nawait provider.import('x', { modelPath: p })","handlingStrategy":"validation","validationCode":"// Verify local file existence before import (URL branch handled separately)\nasync function assertLocalFileExists(p: string) {\n  if (!p.startsWith('https://') && !(await fs.existsSync(p))) {\n    throw new Error(`Model file not found on disk: ${p}. Re-pick the file or pass an https URL.`)\n  }\n}\nawait assertLocalFileExists(opts.modelPath)\nif (opts.mmprojPath) await assertLocalFileExists(opts.mmprojPath)\nif (opts.mtpPath) await assertLocalFileExists(opts.mtpPath)","typeGuard":"async function localFileExists(p: string): Promise<boolean> {\n  if (p.startsWith('https://')) return true\n  return fs.existsSync(p)\n}","tryCatchPattern":"try { await provider.import(modelId, opts) }\ncatch (e) {\n  if (/File not found/.test(String(e))) { opts.modelPath = await rePromptForFile(); await provider.import(modelId, opts) }\n  else throw e\n}","preventionTips":["Resolve symlinks and convert to absolute paths before passing them in.","Validate file existence in the file-picker handler, not at import time.","If a path can be either, branch on https:// explicitly in the UI."],"tags":["model","import","filesystem","local-file","validation"],"backgroundTag":null,"analyzedSha":"fad3f12a147d138388a66f0d92a02b2675f65294","analyzedAt":"2026-08-12T20:33:47.516Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}