{"record":{"id":"4544e955891a2e3e","repo":"janhq/jan","slug":"model-with-id-model-id-already-exists","errorCode":null,"errorMessage":"Model with ID ${model.id} already exists","messagePattern":"Model with ID (.+?) already exists","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extensions/llamacpp-extension/src/index.ts","lineNumber":1825,"sourceCode":"   * @param model\n   */\n  async update(modelId: string, model: Partial<modelInfo>): Promise<void> {\n    const modelFolderPath = await joinPath([\n      await this.getProviderPath(),\n      'models',\n      modelId,\n    ])\n    const modelConfig = await invoke<ModelConfig>('read_yaml', {\n      path: await joinPath([modelFolderPath, 'model.yml']),\n    })\n    const newFolderPath = await joinPath([\n      await this.getProviderPath(),\n      'models',\n      model.id,\n    ])\n    // Check if newFolderPath exists\n    if (await fs.existsSync(newFolderPath)) {\n      throw new Error(`Model with ID ${model.id} already exists`)\n    }\n    const newModelConfigPath = await joinPath([newFolderPath, 'model.yml'])\n    await fs.mv(modelFolderPath, newFolderPath).then(() =>\n      // now replace what values have previous model name with format\n      invoke('write_yaml', {\n        data: {\n          ...modelConfig,\n          model_path: modelConfig?.model_path?.replace(\n            `${this.providerId}/models/${modelId}`,\n            `${this.providerId}/models/${model.id}`\n          ),\n          mmproj_path: modelConfig?.mmproj_path?.replace(\n            `${this.providerId}/models/${modelId}`,\n            `${this.providerId}/models/${model.id}`\n          ),\n        },\n        savePath: newModelConfigPath,\n      })","sourceCodeStart":1807,"sourceCodeEnd":1843,"githubUrl":"https://github.com/janhq/jan/blob/7205d770c1e097c3daf35a911176410e93bc5564/extensions/llamacpp-extension/src/index.ts#L1807-L1843","documentation":"When importing a model, the extension moves the model folder to <providerPath>/models/<model.id>. If a directory with that ID already exists on disk, it throws 'Model with ID ... already exists' to prevent overwriting the existing model's config and weights.","triggerScenarios":"Calling the import flow (llamacpp_extension public method that renames/moves a local model folder) with a model.id that matches an existing folder under the provider's models directory.","commonSituations":"Re-importing the same GGUF twice; importing a model with an ID identical to a previously imported one; leftover folders from a partially deleted model.","solutions":["Choose a different model.id for the import","Delete the existing model folder under <providerPath>/models/<id> if it is no longer wanted","Use the provider's model listing to confirm the existing model before re-importing","If the existing folder is a stale partial import, remove it and retry"],"exampleFix":"// before\nawait importModel({ ...model, id: 'llama-3-8b' }) // already exists\n// after\nawait importModel({ ...model, id: 'llama-3-8b-imported' })","handlingStrategy":"validation","validationCode":"const target = join(providerPath, 'models', model.id)\nif (await fs.existsSync(target)) throw new Error('pick another id or delete first')\nawait importModel(model)","typeGuard":null,"tryCatchPattern":"try {\n  await importModel(model)\n} catch (e) {\n  if (/Model with ID .* already exists/.test(e.message)) {\n    model.id = `${model.id}-${Date.now()}`; await importModel(model)\n  } else throw e\n}","preventionTips":["List existing models before importing","Generate unique IDs (hash of file content) for imports","Clean up stale model folders regularly","Dedupe imports in the UI by checking existing IDs"],"tags":["file-conflict","model-import","duplicate"],"backgroundTag":"file-already-exists","analyzedSha":"7205d770c1e097c3daf35a911176410e93bc5564","analyzedAt":"2026-09-17T14:27:30.100Z","contentChangedAt":"2026-09-17T14:27:30.100Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}