{"record":{"id":"9132b8c393007fc9","repo":"janhq/jan","slug":"model-with-id-model-id-already-exists-9132b8","errorCode":null,"errorMessage":"Model with ID ${model.id} already exists","messagePattern":"Model with ID (.+?) already exists","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"extensions/mlx-extension/src/index.ts","lineNumber":558,"sourceCode":"    modelId: string,\n    model: Partial<modelInfo>\n  ): Promise<void> {\n    // Delegate to the same logic as llamacpp since they share the model dir\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    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      invoke('write_yaml', {\n        data: {\n          ...modelConfig,\n          model_path: modelConfig?.model_path?.replace(\n            `mlx/models/${modelId}`,\n            `mlx/models/${model.id}`\n          ),\n        },\n        savePath: newModelConfigPath,\n      })\n    )\n  }\n\n  override async import(modelId: string, opts: ImportOptions): Promise<void> {\n    if (!isValidModelId(modelId))","sourceCodeStart":540,"sourceCodeEnd":576,"githubUrl":"https://github.com/janhq/jan/blob/fad3f12a147d138388a66f0d92a02b2675f65294/extensions/mlx-extension/src/index.ts#L540-L576","documentation":"Thrown by update() when renaming a model: the destination folder provider/models/<model.id> already exists. update() moves the model folder from modelId to model.id and rewrites model_path; it refuses to clobber an existing model. The check is a pure filesystem existence test.","triggerScenarios":"Calling update() to rename a model to an id that is already taken; a previous failed update left the destination folder behind; two models with ids differing only by casing on a case-insensitive filesystem.","commonSituations":"User picks a new name colliding with another installed model; rename target equals the source (no-op rename); leftover folder from an interrupted prior rename/import.","solutions":["Choose a new model.id that does not match any existing entry in list().","Delete or rename the conflicting existing model first.","If the destination folder is stale leftover (no model.yml), remove it manually then retry.","On case-insensitive filesystems, pick an id that differs by more than case."],"exampleFix":"// before\nawait engine.update(modelId, { id: newId })\n\n// after\nconst dest = await joinPath([await engine.getProviderPath(), 'models', newId])\nif (await fs.existsSync(dest)) {\n  throw new Error(`Name '${newId}' is taken; pick another`)\n}\nawait engine.update(modelId, { id: newId })","handlingStrategy":"validation","validationCode":"async function targetNameFree(providerPath: string, newId: string): Promise<boolean> {\n  return !(await fs.existsSync(await joinPath([providerPath, 'models', newId])))\n}\n\nif (!(await targetNameFree(await engine.getProviderPath(), model.id))) {\n  throw new Error(`Name '${model.id}' already taken`)\n}","typeGuard":null,"tryCatchPattern":"try {\n  await engine.update(modelId, { id: newId })\n} catch (e) {\n  if (/already exists/.test(String(e))) {\n    model.id = `${newId}-2` // pick alternate and retry\n    await engine.update(modelId, { id: model.id })\n  } else throw e\n}","preventionTips":["Check list() for id collisions before renaming.","Delete stale leftover destination folders before retry.","On case-insensitive filesystems, differ by more than case."],"tags":["filesystem","rename","validation","model-config","mlx","typescript"],"backgroundTag":null,"analyzedSha":"fad3f12a147d138388a66f0d92a02b2675f65294","analyzedAt":"2026-08-12T20:33:47.516Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}