{"record":{"id":"6b1ec1d2aed5a357","repo":"nocodb/nocodb","slug":"workspace-not-selected-6b1ec1","errorCode":null,"errorMessage":"Workspace not selected","messagePattern":"Workspace not selected","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/nc-gui/store/workspace.ts","lineNumber":283,"sourceCode":"      },\n    })\n\n    setTheme(fullTheme)\n\n    $e('c:themes:change') */\n  }\n\n  async function clearWorkspaces() {\n    await basesStore.clearBases()\n    workspaces.value.clear()\n  }\n\n  const upgradeActiveWorkspace = async () => {}\n\n  const navigateToWorkspace = async (workspaceId?: string) => {\n    workspaceId = workspaceId || activeWorkspaceId.value!\n    if (!workspaceId) {\n      throw new Error('Workspace not selected')\n    }\n\n    ncNavigateTo({\n      workspaceId,\n    })\n  }\n\n  const navigateToWorkspaceSettings = async (_?: string, cmdOrCtrl?: boolean) => {\n    const workspaceId = activeWorkspaceId.value\n    const path = `/${workspaceId}/more`\n    if (cmdOrCtrl) {\n      await navigateTo(path, {\n        open: navigateToBlankTargetOpenOption,\n      })\n    } else {\n      await navigateTo(path)\n    }\n  }","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/nocodb/nocodb/blob/d3caaf4e890acf64bd49b788cf6dc32b7644c895/packages/nc-gui/store/workspace.ts#L265-L301","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass an explicit workspaceId argument from the caller.","Ensure activeWorkspaceId is resolved (await workspace hydration) before calling.","Guard the call: if (!activeWorkspaceId.value) { await router.push('/workspaces'); return }.","Disable UI triggers of navigateToWorkspace until a workspace is active."],"exampleFix":"// before\nconst navigateToWorkspace = async (workspaceId?: string) => {\n  workspaceId = workspaceId || activeWorkspaceId.value!\n  if (!workspaceId) throw new Error('Workspace not selected')\n  ...\n}\n// after\nconst navigateToWorkspace = async (workspaceId?: string) => {\n  workspaceId = workspaceId || activeWorkspaceId.value\n  if (!workspaceId) { await router.push('/workspaces'); return }\n  ncNavigateTo({ workspaceId })\n}","handlingStrategy":"validation","validationCode":"const targetId = workspaceId || activeWorkspaceId.value\nif (!targetId) {\n  await router.push('/workspaces')\n  return\n}\nncNavigateTo({ workspaceId: targetId })","typeGuard":"const hasWorkspaceTarget = (explicit?: string, active?: string): boolean =>\n  !!explicit || !!active","tryCatchPattern":"try {\n  await navigateToWorkspace(workspaceId)\n} catch (e) {\n  if ((e as Error).message === 'Workspace not selected') {\n    await router.push('/workspaces')\n  } else throw e\n}","preventionTips":["Pass an explicit workspaceId from the caller.","Await workspace hydration before navigating.","Disable navigation triggers until a workspace is active."],"tags":["workspace","navigation","store","precondition"],"backgroundTag":null,"analyzedSha":"d3caaf4e890acf64bd49b788cf6dc32b7644c895","analyzedAt":"2026-08-12T13:07:32.092Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}