{"record":{"id":"b622c7b76c1a509a","repo":"linshenkx/prompt-optimizer","slug":"model-not-found-b622c7","errorCode":null,"errorMessage":"Model not found","messagePattern":"Model not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ui/src/composables/model/useTextModelManager.ts","lineNumber":803,"sourceCode":"    providerId: string,\n    modelId: string,\n    existingConfig?: TextModelConfig\n  ) => resolveTextModelMetadata({\n    providerId,\n    modelId,\n    registry: textAdapterRegistry,\n    existingProviderMeta: existingConfig?.providerMeta,\n    existingModelMeta: existingConfig?.modelMeta\n  })\n\n  const updateExistingModel = async () => {\n    if (!form.value.originalId) {\n      throw new Error('Invalid edit session')\n    }\n\n    const existingConfig = await modelManager.getModel(form.value.originalId)\n    if (!existingConfig) {\n      throw new Error('Model not found')\n    }\n\n    const connectionConfig: TextConnectionConfig = {\n      baseURL: (form.value.connectionConfig.baseURL as string)?.trim() || existingConfig.connectionConfig?.baseURL,\n      ...form.value.connectionConfig\n    }\n\n    if (form.value.displayMaskedKey) {\n      if (form.value.originalApiKey) {\n        connectionConfig.apiKey = form.value.originalApiKey\n      } else {\n        delete connectionConfig.apiKey\n      }\n    } else if (form.value.connectionConfig.apiKey) {\n      connectionConfig.apiKey = form.value.connectionConfig.apiKey\n    } else {\n      delete connectionConfig.apiKey\n    }","sourceCodeStart":785,"sourceCodeEnd":821,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/ui/src/composables/model/useTextModelManager.ts#L785-L821","documentation":"Thrown by updateExistingModel after passing the originalId check but finding that modelManager.getModel(form.value.originalId) returns undefined. The edit session is well-formed but the target model vanished from the registry between opening the form and saving it.","triggerScenarios":"Saving an edit after the model was deleted elsewhere (another tab, another component, external config file edit). Also when the store was reloaded and the model id changed (regenerated key) or when persistence failed silently.","commonSituations":"Long-lived edit dialog over a model deleted in the meantime; concurrent edits from two windows; external modification of the models config file; id regeneration on app upgrade.","solutions":["Catch this error and offer to save as a new model instead of updating","Refresh the models list when the edit window regains focus, warning if the target disappeared","Compare editingModelId with the fresh list before save; if missing, prompt the user","Ensure model ids are stable across persistence rounds (don't regenerate keys on load)"],"exampleFix":"// before\nconst existingConfig = await modelManager.getModel(form.value.originalId)\nif (!existingConfig) throw new Error('Model not found')\n\n// after\nconst existingConfig = await modelManager.getModel(form.value.originalId)\nif (!existingConfig) {\n  form.value.originalId = undefined\n  return createNewModel() // degrade to create\n}","handlingStrategy":"fallback","validationCode":"const stillThere = (await modelManager.getModel(form.value.originalId)) != null\nif (!stillThere) { /* offer save-as-new or abort */ }","typeGuard":"null","tryCatchPattern":"try { await updateExistingModel() } catch (e) { if (String(e?.message) === 'Model not found') { form.value.originalId = undefined; await saveForm() /* recreates */ } else throw e }","preventionTips":["Refresh models when the edit dialog regains focus","Keep model ids stable across persistence loads","Warn users when the edited model disappears from the live list"],"tags":["model-manager","edit-form","concurrent-modification"],"backgroundTag":"entity-deleted-concurrently","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}