stablyai/orca · error · Error

Host not found

Error message

Host not found

What it means

updateHostNameAndEndpoint could not find the given hostId in the stored host list during its atomic name+endpoint mutation. The function runs inside mutateStoredHosts, which loads the current list via readStoredHostProfilesForMutation and findIndex. A -1 index means the host was removed or never existed when the rename/endpoint edit tried to commit.

Source

Thrown at mobile/src/transport/host-store.ts:308

export async function retryPendingHostCredentialCleanup(): Promise<{
  clearedCount: number
  remainingIds: string[]
  storageUnreadable: boolean
}> {
  return retryPendingHostCredentialCleanups((hostId) =>
    deleteUnpairedHostCredentials(hostId, getHostCredentialWriteRevision(hostId))
  )
}

// Why: single mutation pass commits name + endpoint atomically so a mid-save failure can't persist one without the other.
export async function updateHostNameAndEndpoint(
  hostId: string,
  updates: { name?: string; endpoint?: string }
): Promise<void> {
  await mutateStoredHosts((hosts) => {
    const index = hosts.findIndex((host) => host.id === hostId)
    if (index === -1) {
      throw new Error('Host not found')
    }
    const next = hosts.slice()
    next[index] = {
      ...next[index]!,
      ...(updates.name !== undefined ? { name: updates.name } : {}),
      ...(updates.endpoint !== undefined ? { endpoint: updates.endpoint } : {})
    }
    return next
  })
}

export async function updateLastConnected(hostId: string): Promise<void> {
  try {
    await mutateStoredHosts((hosts) => {
      const index = hosts.findIndex((h) => h.id === hostId)
      if (index === -1) {
        return hosts
      }

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Catch 'Host not found' and refresh the host list, then close the edit form with a 'host no longer exists' message.
  2. Reload the host list when the edit screen mounts/focuses to avoid a stale hostId.
  3. Do NOT silently create a new host — that bypasses the user's removal intent.
  4. If the rename is critical, re-resolve the host by publicKeyB64 to find its current ID.

Example fix

// before
const index = hosts.findIndex((host) => host.id === hostId)
if (index === -1) {
  throw new Error('Host not found')
}

// after — caller-side recovery
try {
  await updateHostNameAndEndpoint(hostId, updates)
} catch (e) {
  if (e.message === 'Host not found') {
    await refreshHostList()
    closeEditForm()
    return
  }
  throw e
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify the host still exists before opening the edit form
const hosts = await loadHosts()
if (!hosts.some((h) => h.id === hostId)) {
  closeEditForm()
  return
}

Try / catch

try {
  await updateHostNameAndEndpoint(hostId, updates)
} catch (e) {
  if (e.message === 'Host not found') {
    await refreshHostList()
    closeEditForm()
    return
  }
  throw e
}

Prevention

When it happens

Trigger: User opened the edit-host screen, then the host was removed (by duplicate-key collapse, another tab, or a relay upgrade) before the save landed; hostId is stale after a re-pair that changed the ID; a concurrent removeHost won the mutation chain.

Common situations: Editing a host name while a relay upgrade reassigns the ID; host removed in another screen while the edit form is open; stale hostId after re-pairing the same public key (ID may change); duplicate-key dedup removed the row.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/53aaca686cbbe59f. Report an issue: GitHub.