janhq/jan · error · Error

Invalid backend string: ${targetBackendString} supplied to u

Error message

Invalid backend string: ${targetBackendString} supplied to update function

What it means

Guard at the top of runUpdate: if targetBackendString is falsy (empty string, null, undefined), the function throws immediately before any string parsing. This prevents downstream split('/') logic from operating on a meaningless input.

Source

Thrown at extensions/llamacpp-extension/src/index.ts:1874

    }

    // `runUpdate` clears currentUpdate inside its own body, so a queued
    // continuation chained onto it always observes an idle slot.
    this.currentUpdate = this.runUpdate(targetBackendString)
    return this.currentUpdate
  }

  private async runUpdate(
    targetBackendString: string
  ): Promise<{ wasUpdated: boolean; newBackend: string }> {
    this.isUpdatingBackend = true
    const startedAt = Date.now()
    const from = this.config.version_backend
    let previous: BackendSelection | undefined

    try {
      if (!targetBackendString)
        throw new Error(
          `Invalid backend string: ${targetBackendString} supplied to update function`
        )

      const backendParts = targetBackendString.split('/')

      if (
        backendParts.length !== 2 ||
        !backendParts[0]?.trim() ||
        !backendParts[1]?.trim()
      ) {
        throw new Error(
          `Invalid backend string format: "${targetBackendString}". Expected "version/backend".`
        )
      }

      const [rawVersion, rawBackend] = backendParts
      const version = rawVersion.trim()
      const backend = rawBackend.trim()

View on GitHub (pinned to fad3f12a14)

Solutions

  1. Validate that targetBackendString is a non-empty string before calling runUpdate.
  2. Fix the caller to guarantee a resolved 'version/backend' string (see error 9 for format validation).
  3. Guard the UI so the update action is disabled when no backend is selected.

Example fix

// before
this.runUpdate(selectedBackend)  // selectedBackend could be ''
// after
if (!selectedBackend) throw new Error('No backend selected')
this.runUpdate(selectedBackend)
Defensive patterns

Strategy: validation

Validate before calling

function isValidBackendString(s: unknown): s is string {
  return typeof s === 'string' && s.length > 0
}

// Before calling runUpdate:
if (!isValidBackendString(targetBackendString)) {
  throw new Error('A non-empty backend string is required')
}

Type guard

function isNonEmptyBackendString(s: unknown): s is string {
  return typeof s === 'string' && s.trim().length > 0
}

Prevention

When it happens

Trigger: Calling runUpdate with an empty string, null, or undefined — typically because a caller failed to resolve a backend selection or passed a stale/uninitialized value.

Common situations: A UI dropdown selection event fired with no value; a stored backend preference was cleared but the update was still triggered; a race condition where the backend selection was reset between user click and handler execution.

Related errors


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