nocodb/nocodb · error · Error

Workspace not selected

Error message

Workspace not selected

What it means

In store/bases.loadProjects, when listing for the workspace/home page the code requires an active workspace context. If neither workspace.id nor activeWorkspace.id is set, it throws 'Workspace not selected' before calling $api.base.list, because the list request needs a workspace-scoped baseURL.

Source

Thrown at packages/nc-gui/store/bases.ts:166

          isLoading: false,
        })

        return
      } catch (e: any) {
        if (e?.response?.status === 404) {
          return router.push('/error/404')
        }
        throw e
      } finally {
        isProjectsLoaded.value = true
      }
    }

    const activeWorkspace = workspaceStore.activeWorkspace
    const workspace = workspaceStore.workspace

    if ((!page || page === 'workspace') && !workspace?.id && !activeWorkspace?.id) {
      throw new Error('Workspace not selected')
    }

    let _projects: BaseType[] = []

    isProjectsLoading.value = true
    try {
      const { list } = await $api.base.list({
        baseURL: getBaseUrl(activeWorkspace?.id ?? workspace?.id),
      })
      _projects = list

      bases.value = _projects.reduce((acc, base) => {
        const existingProjectMeta = bases.value.get(base.id!) || {}
        acc.set(base.id!, {
          ...existingProjectMeta,
          ...base,
          isExpanded: route.value.params.baseId === base.id || bases.value.get(base.id!)?.isExpanded,
          isLoading: false,

View on GitHub (pinned to d3caaf4e89)

Solutions

  1. Ensure a workspace is selected (activeWorkspaceId resolved) before navigating to the workspace page.
  2. Redirect to a workspace-picker or onboarding route when no workspace is active.
  3. Seed activeWorkspace from the route param or first available workspace on app init.
  4. Guard the route with a middleware that requires workspaceId.

Example fix

// before
if ((!page || page === 'workspace') && !workspace?.id && !activeWorkspace?.id) throw new Error('Workspace not selected')
// after
if ((!page || page === 'workspace') && !workspace?.id && !activeWorkspace?.id) { await router.push('/workspaces'); return }
Defensive patterns

Strategy: validation

Validate before calling

const wsId = activeWorkspace?.id ?? workspace?.id
if ((!page || page === 'workspace') && !wsId) {
  await router.push('/workspaces')
  return
}

Type guard

const hasWorkspace = (a?: { id?: string }, w?: { id?: string }): boolean =>
  !!a?.id || !!w?.id

Try / catch

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

Prevention

When it happens

Trigger: Navigating to the workspace or home page before a workspace has been chosen/loaded; workspace store cleared (e.g. after logout) while a stale route triggers loadProjects; route enters with page === 'workspace' but no workspaceId in store.

Common situations: Post-logout navigation; deep links that land on the workspace page without a workspace id param; multi-workspace switching where the active workspace is reset to undefined mid-transition.

Related errors


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