{"record":{"id":"3ff1708182636918","repo":"hcengineering/platform","slug":"no-gmail-clients-found-for-social-id","errorCode":null,"errorMessage":"No gmail clients found for social id","messagePattern":"No gmail clients found for social id","errorType":"http","errorClass":null,"httpStatus":404,"severity":"warning","filePath":"services/gmail/pod-gmail/src/main.ts","lineNumber":193,"sourceCode":"      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) => {\n        try {\n          const token = extractToken(req.headers)\n\n          if (token === undefined) {\n            res.status(401).send()","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/services/gmail/pod-gmail/src/main.ts#L175-L211","documentation":"This is an HTTP 404 response body returned by the GET integration-state endpoint in pod-gmail. It means no Gmail client (stored integration state) exists for the given socialId in the workspace, so getState returned undefined. It is a lookup miss, not an internal failure.","triggerScenarios":"Calling GET /integration-state (or equivalent) with a socialId that has never completed Gmail OAuth enrollment, a socialId belonging to another workspace, or a stale/deleted socialId.","commonSituations":"Frontend passes a person/social id from a different system than the one pod-gmail is keyed on; the integration was disconnected and state was deleted; trailing whitespace or URL-encoding differences in the socialId param.","solutions":["Verify the socialId exists in the same workspace's database and matches the id stored when the Gmail client was connected","Re-run the Gmail OAuth connect flow for this socialId so state is persisted","Check for workspace mismatch — pass the socialId scoped to the workspace encoded in the auth context","Log the socialId received vs. known ids to catch encoding/whitespace issues"],"exampleFix":"// before\nconst state = await gmailController.getState(workspace, socialId)\nres.send(state)\n// after\nconst state = await gmailController.getState(workspace, socialId)\nif (state === undefined) {\n  res.status(404).send({ error: 'No gmail clients found for social id' })\n  return\n}\nres.send(state)","handlingStrategy":"validation","validationCode":"if (!socialId) throw new Error('socialId required before querying gmail integration state')\nconst known = await hasGmailClient(workspace, socialId)\nif (!known) console.warn(`no gmail client for socialId=${socialId}`)","typeGuard":"function isStateDefined<T>(state: T | undefined): state is T {\n  return state !== undefined\n}","tryCatchPattern":"try {\n  const res = await fetch(`${base}/integration-state?socialId=${id}`)\n  if (res.status === 404) {\n    console.warn('Gmail not connected for this social id — run connect flow first')\n    return null\n  }\n  return await res.json()\n} catch (e) {\n  console.error('integration-state lookup failed', e)\n  return null\n}","preventionTips":["Confirm socialId comes from the same identity system pod-gmail was enrolled with","Cache which socialIds have completed Gmail OAuth and check before querying","Watch for 404 responses and route users to the connect flow automatically"],"tags":["http-404","gmail","rest-api","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}