{"record":{"id":"1068bf21ac0f40e5","repo":"hcengineering/platform","slug":"workspace-options-workspace-not-found","errorCode":null,"errorMessage":"Workspace ${options.workspace} not found","messagePattern":"Workspace (.+?) not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"foundations/core/packages/api-client/src/client.ts","lineNumber":68,"sourceCode":"  MarkupContent,\n  createMarkupOperations\n} from './markup'\nimport { type ConnectOptions, type PlatformClient, WithMarkup } from './types'\nimport { getWorkspaceToken } from './utils'\n\n/**\n * Create platform client\n * @public */\nexport async function connect (url: string, options: ConnectOptions): Promise<PlatformClient> {\n  const config = await loadServerConfig(url)\n\n  const { endpoint, token } = await getWorkspaceToken(url, options, config)\n  const accountClient = getAccountClient(config.ACCOUNTS_URL, token)\n  const socialIds = await accountClient.getSocialIds(true)\n  const wsLoginInfo = await accountClient.selectWorkspace(options.workspace)\n\n  if (wsLoginInfo === undefined) {\n    throw new Error(`Workspace ${options.workspace} not found`)\n  }\n\n  const account: Account = {\n    uuid: wsLoginInfo.account,\n    role: wsLoginInfo.role,\n    primarySocialId: pickPrimarySocialId(socialIds)._id,\n    socialIds: socialIds.map((si) => si._id),\n    fullSocialIds: socialIds\n  }\n\n  return await createClient(url, endpoint, token, wsLoginInfo.workspace, account, config, options)\n}\n\nasync function createClient (\n  url: string,\n  endpoint: string,\n  token: string,\n  workspaceUuid: WorkspaceUuid,","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/core/packages/api-client/src/client.ts#L50-L86","documentation":"connect() resolves a workspace by name via the accounts service (accountClient.selectWorkspace(options.workspace)). If the accounts service returns no login info for that workspace name, connect throws this Error. It means the named workspace does not exist for the authenticated account (or the account cannot see it).","triggerScenarios":"Calling connect(url, { workspace, ... }) with a workspace name that does not exist, is misspelled, or is not visible to the token's account; selectWorkspace returns undefined and connect throws immediately.","commonSituations":"Wrong workspace name in env/config (e.g. WORKSPACE env var unset or renamed on the server), connecting with a token from a different account that has no membership in the workspace, typos or case differences in workspace name.","solutions":["Verify the workspace name passed in options.workspace matches an existing workspace for that account (check server admin or account workspace list).","Confirm the token used to authenticate belongs to an account with access to the workspace.","Check the environment/config value (env var or connect argument) for typos, whitespace, or case mismatch.","Catch the error and surface a clear message listing valid workspace names."],"exampleFix":"// before\nawait connect(url, { workspace: process.env.WORKSPACE, token })\n// after\nconst ws = process.env.WORKSPACE?.trim()\nif (!ws) throw new Error('WORKSPACE env var is not set')\nawait connect(url, { workspace: ws, token })","handlingStrategy":"try-catch","validationCode":"const ws = options.workspace?.trim()\nif (!ws) throw new Error('workspace name is required')","typeGuard":"function hasWorkspace(o: unknown): o is { workspace: string } {\n  return typeof o === 'object' && o !== null && typeof (o as any).workspace === 'string' && (o as any).workspace.length > 0\n}","tryCatchPattern":"try {\n  await connect(url, { workspace, token })\n} catch (e) {\n  if (e instanceof Error && e.message.includes('not found') && e.message.includes('Workspace')) {\n    throw new Error(`Workspace \"${workspace}\" does not exist or the account has no access; verify the workspace name and token`)\n  }\n  throw e\n}","preventionTips":["Load workspace name from a single validated config source, not ad-hoc literals","Trim and validate the workspace value before calling connect","Confirm token and workspace belong to the same account in staging before production runs"],"tags":["workspace","authentication","configuration"],"backgroundTag":"workspace-not-found","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}