{"record":{"id":"08ceb4ba2ab37488","repo":"hcengineering/platform","slug":"workspace-not-found","errorCode":null,"errorMessage":"Workspace not found","messagePattern":"Workspace not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"foundations/core/packages/api-client/src/utils.ts","lineNumber":51,"sourceCode":"  config ??= await loadServerConfig(url)\n\n  let token: string | undefined\n\n  if ('token' in options) {\n    token = options.token\n  } else {\n    const { email, password } = options\n    const loginInfo = await getAccountClient(config.ACCOUNTS_URL).login(email, password)\n    token = loginInfo.token\n  }\n\n  if (token === undefined) {\n    throw new Error('Login failed')\n  }\n\n  const ws = await getAccountClient(config.ACCOUNTS_URL, token).selectWorkspace(options.workspace)\n  if (ws === undefined) {\n    throw new Error('Workspace not found')\n  }\n\n  return { endpoint: ws.endpoint, token: ws.token, workspaceId: ws.workspace, info: ws }\n}\n","sourceCodeStart":33,"sourceCodeEnd":56,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/core/packages/api-client/src/utils.ts#L33-L56","documentation":"After successful authentication, getWorkspaceToken calls selectWorkspace to find the requested workspace for the account. If the accounts service returns no matching workspace, it throws 'Workspace not found'. Authentication succeeded but the account has no access to (or does not have) that workspace.","triggerScenarios":"getWorkspaceToken called with options.workspace naming a workspace that does not exist, was renamed/deleted, or the authenticated account is not a member of.","commonSituations":"Typo in workspace name/URL in config or env; user removed from the workspace; workspace deleted; connecting against the wrong deployment (e.g. prod workspace name on dev accounts service).","solutions":["Verify the workspace name/identifier matches an existing workspace for that account.","Confirm the account is still a member of the target workspace.","Check you are pointing at the correct deployment's ACCOUNTS_URL.","List the account's workspaces (via the account client) to see valid names.","Handle the error in onboarding flows to prompt the user to pick a valid workspace."],"exampleFix":"// before\nconst conn = await connect(token, workspace)\n// after\nconst ws = await getAccountClient(config.ACCOUNTS_URL, token).selectWorkspace(workspace)\nif (ws === undefined) {\n  throw new Error(`Workspace \"${workspace}\" not found for this account`)\n}\nconst conn = await connect(token, workspace)","handlingStrategy":"validation","validationCode":"const wsList = await getAccountClient(config.ACCOUNTS_URL, token).listWorkspaces(account)\nif (!wsList.some(w => w.name === workspace)) {\n  throw new Error(`Workspace \"${workspace}\" not available for this account`)\n}","typeGuard":"function workspaceExists(ws: { name: string }[] | undefined, name: string): ws is { name: string }[] {\n  return ws?.some(w => w.name === name) === true\n}","tryCatchPattern":"try {\n  const { token, endpoint } = await getWorkspaceToken(opts)\n} catch (err) {\n  if (err.message === 'Workspace not found') {\n    console.error(`Workspace \"${opts.workspace}\" missing — check name/membership`)\n    throw err\n  }\n  throw err\n}","preventionTips":["List the account's workspaces and validate the target name before connecting","Confirm workspace names per environment (dev vs prod)","Check membership after workspace invites/removals","Present a workspace picker on this error instead of failing hard"],"tags":["authentication","workspace","config"],"backgroundTag":"workspace-not-found","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}