hcengineering/platform · warning

Missing socialId param

Error message

Missing socialId param

What it means

The /state endpoint requires the socialId query parameter identifying the social/account identity whose Gmail client state is being queried. If socialId is missing or empty, the endpoint responds 400 with this fixed error message. It is explicit parameter validation before hitting the controller.

Source

Thrown at services/gmail/pod-gmail/src/main.ts:188

        }
      }
    },
    {
      endpoint: '/state',
      type: 'get',
      handler: async (req, res) => {
        try {
          const token = extractToken(req.headers)

          if (token === undefined) {
            res.status(401).send()
            return
          }

          const { workspace } = decodeToken(token)
          const socialId = req.query.socialId as PersonId | undefined
          if (socialId == null || socialId === '') {
            res.status(400).send({ error: 'Missing socialId param' })
            return
          }
          const state = await gmailController.getState(workspace, socialId)
          if (state === undefined) {
            res.status(404).send({ error: 'No gmail clients found for social id' })
            return
          }
          res.send(state)
        } catch (err: any) {
          ctx.error('Failed to get integration state', { message: err.message })
          res.status(500).send({ error: err.message })
        }
      }
    },
    {
      endpoint: '/start-sync',
      type: 'post',
      handler: async (req, res) => {

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Append the socialId query parameter with the person's social/account id to the request URL.
  2. Fix client-side parameter naming so it is exactly 'socialId'.
  3. Resolve the correct PersonId from the workspace data before calling /state.

Example fix

// before
await fetch(url + '/state', { headers })
// after
await fetch(url + `/state?socialId=${encodeURIComponent(socialId)}`, { headers })
Defensive patterns

Strategy: validation

Validate before calling

if (!socialId || typeof socialId !== 'string') {
  throw new Error('socialId is required to query gmail integration state')
}
const res = await fetch(`${url}/state?socialId=${encodeURIComponent(socialId)}`, { headers })

Type guard

function hasSocialId(v: unknown): v is string {
  return typeof v === 'string' && v.length > 0
}

Try / catch

const res = await fetch(stateUrl, { headers })
if (res.status === 400) {
  const body = await res.json()
  if (body?.error === 'Missing socialId param') {
    // fix the client to include the socialId query parameter
  }
} else if (res.status === 404) {
  // no gmail clients for this social id — user has not connected gmail
}

Prevention

When it happens

Trigger: GET /state with no socialId query parameter, an empty value (?socialId=), or a null value, even though the request itself is properly authenticated.

Common situations: Client not resolving the PersonId/social id before querying state; UI sending undefined when no account is connected; parameter name typo (e.g. socialID) so the expected param is absent.

Related errors


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