nocodb/nocodb · error · Error

Workspace not selected

Error message

Workspace not selected

What it means

workspace.navigateToWorkspace requires a workspace id: it uses the argument, else falls back to activeWorkspaceId.value!. If both are empty it throws 'Workspace not selected' before ncNavigateTo, since navigation needs a concrete workspaceId to build the route.

Source

Thrown at packages/nc-gui/store/workspace.ts:283

      },
    })

    setTheme(fullTheme)

    $e('c:themes:change') */
  }

  async function clearWorkspaces() {
    await basesStore.clearBases()
    workspaces.value.clear()
  }

  const upgradeActiveWorkspace = async () => {}

  const navigateToWorkspace = async (workspaceId?: string) => {
    workspaceId = workspaceId || activeWorkspaceId.value!
    if (!workspaceId) {
      throw new Error('Workspace not selected')
    }

    ncNavigateTo({
      workspaceId,
    })
  }

  const navigateToWorkspaceSettings = async (_?: string, cmdOrCtrl?: boolean) => {
    const workspaceId = activeWorkspaceId.value
    const path = `/${workspaceId}/more`
    if (cmdOrCtrl) {
      await navigateTo(path, {
        open: navigateToBlankTargetOpenOption,
      })
    } else {
      await navigateTo(path)
    }
  }

View on GitHub (pinned to d3caaf4e89)

Solutions

  1. Pass an explicit workspaceId argument from the caller.
  2. Ensure activeWorkspaceId is resolved (await workspace hydration) before calling.
  3. Guard the call: if (!activeWorkspaceId.value) { await router.push('/workspaces'); return }.
  4. Disable UI triggers of navigateToWorkspace until a workspace is active.

Example fix

// before
const navigateToWorkspace = async (workspaceId?: string) => {
  workspaceId = workspaceId || activeWorkspaceId.value!
  if (!workspaceId) throw new Error('Workspace not selected')
  ...
}
// after
const navigateToWorkspace = async (workspaceId?: string) => {
  workspaceId = workspaceId || activeWorkspaceId.value
  if (!workspaceId) { await router.push('/workspaces'); return }
  ncNavigateTo({ workspaceId })
}
Defensive patterns

Strategy: validation

Validate before calling

const targetId = workspaceId || activeWorkspaceId.value
if (!targetId) {
  await router.push('/workspaces')
  return
}
ncNavigateTo({ workspaceId: targetId })

Type guard

const hasWorkspaceTarget = (explicit?: string, active?: string): boolean =>
  !!explicit || !!active

Try / catch

try {
  await navigateToWorkspace(workspaceId)
} catch (e) {
  if ((e as Error).message === 'Workspace not selected') {
    await router.push('/workspaces')
  } else throw e
}

Prevention

When it happens

Trigger: Calling navigateToWorkspace() (no arg) when activeWorkspaceId is null/undefined — e.g. right after logout, before workspace hydration, or in a context where the workspace store has been cleared.

Common situations: UI buttons that call navigateToWorkspace without an id and rely on activeWorkspaceId that has not been set; post-logout redirects; deep-link entry points that bypass workspace selection.

Related errors


AI-assisted analysis of nocodb/nocodb@d3caaf4e89 (2026-08-12). Data as JSON: /api/errors/6b1ec1d2aed5a357. Report an issue: GitHub.