janhq/jan · warning · Error

Current backend not found

Error message

Current backend not found

What it means

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.

Source

Thrown at web-app/src/hooks/useBackendUpdater.ts:45

  wasUpdated: boolean
  reason?: 'in_progress' | 'error' | string
}

interface ExtensionWithSettings {
  getSettings?: () => Promise<ExtensionSetting[] | undefined>
}

async function getCurrentBackendTypeFromSettings(
  extension: ExtensionWithSettings
): Promise<string> {
  const settings = await extension.getSettings?.()
  const backendSetting = settings?.find((s) => s.key === 'llamacpp_backend')
  const currentBackendType = (
    backendSetting?.controllerProps?.value as string | undefined
  )?.trim()

  if (!currentBackendType) {
    throw new Error('Current backend not found')
  }

  return currentBackendType
}

interface LlamacppExtension {
  getSettings?(): Promise<ExtensionSetting[]>
  checkBackendForUpdates?(): Promise<BackendUpdateInfo>
  updateBackend?(
    targetBackend: string
  ): Promise<{ wasUpdated: boolean; newBackend: string }>
  installBackend?(filePath: string): Promise<void>
  installCudaRuntime?(filePath: string): Promise<void>
  configureBackends?(): Promise<void>
  refreshBackendOptions?(): Promise<void>
}

export interface BackendUpdateState {

View on GitHub (pinned to fad3f12a14)

Solutions

  1. Ensure a backend is selected in llamacpp settings before triggering an update (open settings, pick a backend).
  2. Have the extension seed a default `llamacpp_backend` value on first run.
  3. When this throws, catch it and prompt the user to choose a backend instead of failing the update silently.

Example fix

// before
const currentBackendType = (
  backendSetting?.controllerProps?.value as string | undefined
)?.trim()
if (!currentBackendType) {
  throw new Error('Current backend not found')
}

// after
const currentBackendType = (
  backendSetting?.controllerProps?.value as string | undefined
)?.trim()
if (!currentBackendType) {
  throw new Error(
    'No llamacpp backend is currently selected. Choose one in Settings > llama.cpp before updating.'
  )
}
Defensive patterns

Strategy: validation

Validate before calling

const settings = await extension.getSettings?.()
const backend = settings?.find((s) => s.key === 'llamacpp_backend')?.controllerProps?.value
if (!backend || !String(backend).trim()) {
  // prompt user to pick a backend before update
  toast.error('No backend selected', { description: 'Choose a backend in Settings > llama.cpp first.' })
  return
}

Type guard

function hasBackendSetting(settings: ExtensionSetting[] | undefined): settings is (ExtensionSetting & { controllerProps: { value: string } })[] {
  return !!settings && settings.some((s) => s.key === 'llamacpp_backend' && typeof s.controllerProps?.value === 'string' && s.controllerProps.value.trim().length > 0)
}

Try / catch

try {
  const currentBackendType = await getCurrentBackendTypeFromSettings(extension)
  // proceed
} catch (error) {
  // No backend chosen yet — guide the user instead of failing the update.
  toast.error('No llamacpp backend selected', { description: 'Choose one in Settings > llama.cpp before updating.' })
  return
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of janhq/jan@fad3f12a14 (2026-08-12). Data as JSON: /api/errors/d492ed4f56751cde. Report an issue: GitHub.