{"record":{"id":"5f40aa6e4b21ae69","repo":"hcengineering/platform","slug":"missing-socialid-param","errorCode":null,"errorMessage":"Missing socialId param","messagePattern":"Missing socialId param","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"services/gmail/pod-gmail/src/main.ts","lineNumber":188,"sourceCode":"        }\n      }\n    },\n    {\n      endpoint: '/state',\n      type: 'get',\n      handler: async (req, res) => {\n        try {\n          const token = extractToken(req.headers)\n\n          if (token === undefined) {\n            res.status(401).send()\n            return\n          }\n\n          const { workspace } = decodeToken(token)\n          const socialId = req.query.socialId as PersonId | undefined\n          if (socialId == null || socialId === '') {\n            res.status(400).send({ error: 'Missing socialId param' })\n            return\n          }\n          const state = await gmailController.getState(workspace, socialId)\n          if (state === undefined) {\n            res.status(404).send({ error: 'No gmail clients found for social id' })\n            return\n          }\n          res.send(state)\n        } catch (err: any) {\n          ctx.error('Failed to get integration state', { message: err.message })\n          res.status(500).send({ error: err.message })\n        }\n      }\n    },\n    {\n      endpoint: '/start-sync',\n      type: 'post',\n      handler: async (req, res) => {","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/services/gmail/pod-gmail/src/main.ts#L170-L206","documentation":"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.","triggerScenarios":"GET /state with no socialId query parameter, an empty value (?socialId=), or a null value, even though the request itself is properly authenticated.","commonSituations":"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.","solutions":["Append the socialId query parameter with the person's social/account id to the request URL.","Fix client-side parameter naming so it is exactly 'socialId'.","Resolve the correct PersonId from the workspace data before calling /state."],"exampleFix":"// before\nawait fetch(url + '/state', { headers })\n// after\nawait fetch(url + `/state?socialId=${encodeURIComponent(socialId)}`, { headers })","handlingStrategy":"validation","validationCode":"if (!socialId || typeof socialId !== 'string') {\n  throw new Error('socialId is required to query gmail integration state')\n}\nconst res = await fetch(`${url}/state?socialId=${encodeURIComponent(socialId)}`, { headers })","typeGuard":"function hasSocialId(v: unknown): v is string {\n  return typeof v === 'string' && v.length > 0\n}","tryCatchPattern":"const res = await fetch(stateUrl, { headers })\nif (res.status === 400) {\n  const body = await res.json()\n  if (body?.error === 'Missing socialId param') {\n    // fix the client to include the socialId query parameter\n  }\n} else if (res.status === 404) {\n  // no gmail clients for this social id — user has not connected gmail\n}","preventionTips":["Resolve the PersonId/social id before querying integration state.","Use the exact parameter name 'socialId' in the query string.","Handle the 404 'No gmail clients found for social id' case as 'not connected', not as a bug."],"tags":["validation","http-400","http-handler"],"backgroundTag":"missing-required-query-param","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}