hcengineering/platform · error · ApiError

Social ID is missing

Error message

Social ID is missing

What it means

After the token is validated (isWorkspaceLoginInfo passed), handleRequest requires wsLoginInfo.socialId to construct the workspace ids used by the exporter. If the account service returned workspace login info whose socialId field is undefined, the request is rejected with this 401. The token is valid but the account behind it has no social identity attached.

Source

Thrown at services/export/pod-export/src/server.ts:239

  token: string,
  socialId: PersonId,
  next: NextFunction
) => Promise<void>

const handleRequest = async (
  fn: AsyncRequestHandler,
  req: Request,
  res: Response,
  next: NextFunction
): Promise<void> => {
  try {
    const token = retrieveToken(req.headers, req.query)
    const wsLoginInfo = await getAccountClient(token).getLoginInfoByToken()
    if (!isWorkspaceLoginInfo(wsLoginInfo)) {
      throw new ApiError(401, "Couldn't find workspace with the provided token")
    }
    if (wsLoginInfo.socialId === undefined) {
      throw new ApiError(401, 'Social ID is missing')
    }
    const wsIds = {
      uuid: wsLoginInfo.workspace,
      dataId: wsLoginInfo.workspaceDataId,
      url: wsLoginInfo.workspaceUrl
    }
    await fn(req, res, wsIds, token, wsLoginInfo.socialId, next)
  } catch (err: unknown) {
    next(err)
  }
}

const wrapRequest = (fn: AsyncRequestHandler) => (req: Request, res: Response, next: NextFunction) => {
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
  handleRequest(fn, req, res, next)
}

// Only formats actually supported by WorkspaceExporter

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Link a social account to the workspace/user in the account service so getLoginInfoByToken returns a socialId.
  2. Verify with the account service that the token's account record has a socialId field populated.
  3. If this is a provisioned test workspace, create it through the normal signup flow or backfill the socialId.

Example fix

// before
// token valid, but account has no socialId -> 401
const wsLoginInfo = await getAccountClient(token).getLoginInfoByToken()
// after
// ensure account is linked to a social identity before calling export
// account.socialId = 'xxx:yyy' (set via account service), then retry
Defensive patterns

Strategy: validation

Validate before calling

const info = await getAccountClient(token).getLoginInfoByToken()
if (info?.socialId === undefined) { throw new Error('Account has no socialId; link a social account before exporting') }

Type guard

function hasSocialId(v: unknown): v is { socialId: string } {
  return typeof v === 'object' && v !== null && typeof (v as any).socialId === 'string'
}

Try / catch

try {
  await exportWorkspace(params)
} catch (e) {
  if (e instanceof ApiError && e.message === 'Social ID is missing') {
    throw new Error('Workspace account lacks a social identity; fix the account record, not the request')
  }
  throw e
}

Prevention

When it happens

Trigger: A workspace token resolving to login info where socialId === undefined, i.e. the account/workspace was created without a linked social account (no socialId in the account record).

Common situations: Workspaces provisioned via automation/backdoor without social integration; accounts migrated between instances losing the social binding; test fixtures with partial login info.

Related errors


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