{"record":{"id":"f2235e03a624bdfb","repo":"janhq/jan","slug":"model-modelid-already-exists-f2235e","errorCode":null,"errorMessage":"Model ${modelId} already exists","messagePattern":"Model (.+?) already exists","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"extensions/mlx-extension/src/index.ts","lineNumber":618,"sourceCode":"        savePath: newModelConfigPath,\n      })\n    )\n  }\n\n  override async import(modelId: string, opts: ImportOptions): Promise<void> {\n    if (!isValidModelId(modelId))\n      throw new Error(\n        `Invalid modelId: ${modelId}. Only alphanumeric and / _ - . characters are allowed.`\n      )\n\n    const configPath = await joinPath([\n      await this.getProviderPath(),\n      'models',\n      modelId,\n      'model.yml',\n    ])\n    if (await fs.existsSync(configPath))\n      throw new Error(`Model ${modelId} already exists`)\n\n    const sourcePath = opts.modelPath\n\n    if (sourcePath.startsWith('https://')) {\n      // Download from URL to mlx models folder\n      const janDataFolderPath = await getJanDataFolderPath()\n      const modelDir = await joinPath([\n        janDataFolderPath,\n        'mlx',\n        'models',\n        modelId,\n      ])\n      const localPath = await joinPath([modelDir, 'model.safetensors'])\n\n      const downloadManager = window.core.extensionManager.getByName(\n        '@janhq/download-extension'\n      )\n","sourceCodeStart":600,"sourceCodeEnd":636,"githubUrl":"https://github.com/janhq/jan/blob/7205d770c1e097c3daf35a911176410e93bc5564/extensions/mlx-extension/src/index.ts#L600-L636","documentation":"import() checks whether providerPath/models/<modelId>/model.yml already exists before importing. If the model directory is already present, it refuses to overwrite and throws this error to protect the existing model configuration.","triggerScenarios":"Calling MlxExtension.import(modelId, opts) when a model with the identical modelId was previously imported and its model.yml still exists on disk.","commonSituations":"Re-running an import script twice; re-importing after a partial/cancelled download that still left model.yml; name collision between an org/repo id and an existing local model; upgrading a model without deleting the old directory.","solutions":["Delete the existing model directory (providerPath/models/<modelId>) or call the extension's delete method before importing","Choose a different, unique modelId","Check existence first (fs.existsSync on the model.yml path) and skip or update instead of importing","If the earlier import failed mid-way, remove leftover files then retry"],"exampleFix":"// before\nawait mlx.import('mlx-community/Llama-3-8B', opts) // throws if it exists\n// after\nconst existing = await mlx.getModels().then(ms => ms.some(m => m.id === 'mlx-community/Llama-3-8B'))\nif (!existing) await mlx.import('mlx-community/Llama-3-8B', opts)","handlingStrategy":"validation","validationCode":"import fs from 'path-browserify'\nconst configPath = await joinPath([await mlx.getProviderPath(), 'models', modelId, 'model.yml'])\nif (await fs.existsSync(configPath)) return // or update/delete first","typeGuard":null,"tryCatchPattern":"try {\n  await mlx.import(modelId, opts)\n} catch (e) {\n  if (String(e).includes('already exists')) {\n    await mlx.delete(modelId)\n    await mlx.import(modelId, opts)\n  } else throw e\n}","preventionTips":["Check for an existing model with the same id before importing","Make imports idempotent: skip or update when model.yml exists","Clean up leftover directories from failed imports before retrying","Use unique ids (org/repo or timestamp suffix) for repeated imports"],"tags":["duplicate","filesystem","model-import"],"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"}