{"record":{"id":"d492ed4f56751cde","repo":"janhq/jan","slug":"current-backend-not-found","errorCode":null,"errorMessage":"Current backend not found","messagePattern":"Current backend not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"web-app/src/hooks/useBackendUpdater.ts","lineNumber":45,"sourceCode":"  wasUpdated: boolean\n  reason?: 'in_progress' | 'error' | string\n}\n\ninterface ExtensionWithSettings {\n  getSettings?: () => Promise<ExtensionSetting[] | undefined>\n}\n\nasync function getCurrentBackendTypeFromSettings(\n  extension: ExtensionWithSettings\n): Promise<string> {\n  const settings = await extension.getSettings?.()\n  const backendSetting = settings?.find((s) => s.key === 'llamacpp_backend')\n  const currentBackendType = (\n    backendSetting?.controllerProps?.value as string | undefined\n  )?.trim()\n\n  if (!currentBackendType) {\n    throw new Error('Current backend not found')\n  }\n\n  return currentBackendType\n}\n\ninterface LlamacppExtension {\n  getSettings?(): Promise<ExtensionSetting[]>\n  checkBackendForUpdates?(): Promise<BackendUpdateInfo>\n  updateBackend?(\n    targetBackend: string\n  ): Promise<{ wasUpdated: boolean; newBackend: string }>\n  installBackend?(filePath: string): Promise<void>\n  installCudaRuntime?(filePath: string): Promise<void>\n  configureBackends?(): Promise<void>\n  refreshBackendOptions?(): Promise<void>\n}\n\nexport interface BackendUpdateState {","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/janhq/jan/blob/fad3f12a147d138388a66f0d92a02b2675f65294/web-app/src/hooks/useBackendUpdater.ts#L27-L63","documentation":"Thrown by `getCurrentBackendTypeFromSettings` when the llamacpp extension's settings array has no entry with key `llamacpp_backend`, or its `controllerProps.value` is empty/whitespace. The function is used to construct a `version/backendType` target string for `updateBackend` when `updateInfo.targetBackend` is absent or malformed.","triggerScenarios":"Called during backend update when `targetBackendString` is empty or malformed — fallback reads settings, but the `llamacpp_backend` setting was never persisted (fresh install before first backend selection), was reset, or uses a different key after an extension rename.","commonSituations":"First-run state where no backend has been chosen yet; settings schema changed between extension versions; the controllerProps value is null/undefined rather than a string; user manually cleared settings.","solutions":["Ensure a backend is selected in llamacpp settings before triggering an update (open settings, pick a backend).","Have the extension seed a default `llamacpp_backend` value on first run.","When this throws, catch it and prompt the user to choose a backend instead of failing the update silently."],"exampleFix":"// before\nconst currentBackendType = (\n  backendSetting?.controllerProps?.value as string | undefined\n)?.trim()\nif (!currentBackendType) {\n  throw new Error('Current backend not found')\n}\n\n// after\nconst currentBackendType = (\n  backendSetting?.controllerProps?.value as string | undefined\n)?.trim()\nif (!currentBackendType) {\n  throw new Error(\n    'No llamacpp backend is currently selected. Choose one in Settings > llama.cpp before updating.'\n  )\n}","handlingStrategy":"validation","validationCode":"const settings = await extension.getSettings?.()\nconst backend = settings?.find((s) => s.key === 'llamacpp_backend')?.controllerProps?.value\nif (!backend || !String(backend).trim()) {\n  // prompt user to pick a backend before update\n  toast.error('No backend selected', { description: 'Choose a backend in Settings > llama.cpp first.' })\n  return\n}","typeGuard":"function hasBackendSetting(settings: ExtensionSetting[] | undefined): settings is (ExtensionSetting & { controllerProps: { value: string } })[] {\n  return !!settings && settings.some((s) => s.key === 'llamacpp_backend' && typeof s.controllerProps?.value === 'string' && s.controllerProps.value.trim().length > 0)\n}","tryCatchPattern":"try {\n  const currentBackendType = await getCurrentBackendTypeFromSettings(extension)\n  // proceed\n} catch (error) {\n  // No backend chosen yet — guide the user instead of failing the update.\n  toast.error('No llamacpp backend selected', { description: 'Choose one in Settings > llama.cpp before updating.' })\n  return\n}","preventionTips":["Seed a default llamacpp_backend value on first run.","Guard the update flow with a backend-selected check in the UI.","Catch this specific error to convert it into a setup prompt."],"tags":["llamacpp","settings","backend","configuration"],"backgroundTag":null,"analyzedSha":"fad3f12a147d138388a66f0d92a02b2675f65294","analyzedAt":"2026-08-12T20:33:47.516Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}