hcengineering/platform · warning · PlatformError

addSession: getWorkspaceInfo failed

Error message

addSession: getWorkspaceInfo failed

What it means

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.

Source

Thrown at foundations/server/packages/server/src/sessionManager.ts:737

            return { error: err, terminate: true }
          }

          if (account === undefined) {
            return { error: new Error('Account not found or not available'), terminate: true }
          }

          let wsInfo = account.workspaces[token.workspace]

          if (wsInfo === undefined) {
            // In case of guest or system account
            // We need to get workspace info for system account.
            let workspaceInfo: WorkspaceInfoWithStatus | undefined
            try {
              workspaceInfo =
                this.workspaceInfoCache.get(token.workspace) ?? (await this.getWorkspaceInfo(ctx, rawToken, false))
            } catch (err: unknown) {
              if (err instanceof PlatformError) {
                ctx.warn('addSession: getWorkspaceInfo failed', {
                  workspaceUuid: token.workspace,
                  code: err.status.code,
                  source: token.extra?.service ?? '🤦‍♂️user'
                })
                return { error: err.status, terminate: true }
              }
              throw err
            }
            if (workspaceInfo === undefined) {
              return { error: new Error('Workspace not found or not available'), terminate: true }
            }
            this.workspaceInfoCache.set(token.workspace, workspaceInfo)

            wsInfo = {
              url: workspaceInfo.url,
              mode: workspaceInfo.mode,
              dataId: workspaceInfo.dataId,
              version: {

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Re-authenticate to get a token for a valid, active workspace
  2. Check account service health and connectivity
  3. Verify the workspace UUID still exists and is not archived
  4. Inspect the returned err.status.code to distinguish not-found vs service failure

Example fix

// before
const ws = token.workspace // deleted workspace uuid
socket.connect({ token })
// after
const info = await accountClient.getWorkspaceInfo(token.workspace)
if (!info || info.status.code !== OK) {
  token = await reauthenticateWithValidWorkspace()
}
socket.connect({ token })
Defensive patterns

Strategy: try-catch

Validate before calling

const info = await accountClient.getWorkspaceInfo(token.workspace)
if (!info || info.status?.code !== OK) {
  throw new Error(`workspace ${token.workspace} unavailable`)
}

Type guard

function isPlatformError(e: unknown): e is PlatformError {
  return e instanceof PlatformError
}

Try / catch

try {
  await connect(token)
} catch (err) {
  if (isPlatformError(err)) {
    handleSessionError(err.status) // surface code, prompt re-login
  } else throw err
}

Prevention

When it happens

Trigger: 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).

Common situations: Stale tokens referencing deleted workspaces; account service down or unreachable; workspace archived after token issuance; typo'd workspace UUID in tokens.

Related errors


AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29). Data as JSON: /api/errors/c5d74e9e809d90b3. Report an issue: GitHub.