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
- 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.
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
- Pass an explicit workspaceId from the caller.
- Await workspace hydration before navigating.
- Disable navigation triggers until a workspace is active.
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
- Workspace not selected
- Base not found
- Base not found
- Delete not allowed for table which doesn't have primary Key
- Table not found
AI-assisted analysis of nocodb/nocodb@d3caaf4e89 (2026-08-12).
Data as JSON: /api/errors/6b1ec1d2aed5a357.
Report an issue: GitHub.