{"record":{"id":"c5d74e9e809d90b3","repo":"hcengineering/platform","slug":"addsession-getworkspaceinfo-failed","errorCode":null,"errorMessage":"addSession: getWorkspaceInfo failed","messagePattern":"addSession: getWorkspaceInfo failed","errorType":"error_code","errorClass":"PlatformError","httpStatus":null,"severity":"warning","filePath":"foundations/server/packages/server/src/sessionManager.ts","lineNumber":737,"sourceCode":"            return { error: err, terminate: true }\n          }\n\n          if (account === undefined) {\n            return { error: new Error('Account not found or not available'), terminate: true }\n          }\n\n          let wsInfo = account.workspaces[token.workspace]\n\n          if (wsInfo === undefined) {\n            // In case of guest or system account\n            // We need to get workspace info for system account.\n            let workspaceInfo: WorkspaceInfoWithStatus | undefined\n            try {\n              workspaceInfo =\n                this.workspaceInfoCache.get(token.workspace) ?? (await this.getWorkspaceInfo(ctx, rawToken, false))\n            } catch (err: unknown) {\n              if (err instanceof PlatformError) {\n                ctx.warn('addSession: getWorkspaceInfo failed', {\n                  workspaceUuid: token.workspace,\n                  code: err.status.code,\n                  source: token.extra?.service ?? '🤦‍♂️user'\n                })\n                return { error: err.status, terminate: true }\n              }\n              throw err\n            }\n            if (workspaceInfo === undefined) {\n              return { error: new Error('Workspace not found or not available'), terminate: true }\n            }\n            this.workspaceInfoCache.set(token.workspace, workspaceInfo)\n\n            wsInfo = {\n              url: workspaceInfo.url,\n              mode: workspaceInfo.mode,\n              dataId: workspaceInfo.dataId,\n              version: {","sourceCodeStart":719,"sourceCodeEnd":755,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/server/packages/server/src/sessionManager.ts#L719-L755","documentation":"During WebSocket session establishment, addSession resolves the workspace via cache or getWorkspaceInfo. If that call raises a PlatformError (rejected by the account service), the failure is logged with this message, the status code is returned to the client, and the connection is terminated.","triggerScenarios":"Connecting a session whose token's workspace UUID does not exist, is disabled/removed, or when the account service returns any PlatformError while fetching workspace info (e.g. transient account-service failure).","commonSituations":"Stale tokens referencing deleted workspaces; account service down or unreachable; workspace archived after token issuance; typo'd workspace UUID in tokens.","solutions":["Re-authenticate to get a token for a valid, active workspace","Check account service health and connectivity","Verify the workspace UUID still exists and is not archived","Inspect the returned err.status.code to distinguish not-found vs service failure"],"exampleFix":"// before\nconst ws = token.workspace // deleted workspace uuid\nsocket.connect({ token })\n// after\nconst info = await accountClient.getWorkspaceInfo(token.workspace)\nif (!info || info.status.code !== OK) {\n  token = await reauthenticateWithValidWorkspace()\n}\nsocket.connect({ token })","handlingStrategy":"try-catch","validationCode":"const info = await accountClient.getWorkspaceInfo(token.workspace)\nif (!info || info.status?.code !== OK) {\n  throw new Error(`workspace ${token.workspace} unavailable`)\n}","typeGuard":"function isPlatformError(e: unknown): e is PlatformError {\n  return e instanceof PlatformError\n}","tryCatchPattern":"try {\n  await connect(token)\n} catch (err) {\n  if (isPlatformError(err)) {\n    handleSessionError(err.status) // surface code, prompt re-login\n  } else throw err\n}","preventionTips":["Check workspace validity before issuing tokens","Monitor account service health; add circuit breakers","Expire tokens when their workspace is removed","Surface status codes to users with actionable messaging"],"tags":["typescript","session","websocket","account-service"],"backgroundTag":"workspace-lookup-failed","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}