{"record":{"id":"b34213786f3a3718","repo":"hcengineering/platform","slug":"user-is-not-signed-in","errorCode":null,"errorMessage":"User is not signed in","messagePattern":"User is not signed in","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"services/telegram/pod-telegram/src/platform.ts","lineNumber":54,"sourceCode":"      wsWorker = await WorkspaceWorker.create(\n        this.ctx,\n        this.storageAdapter,\n        workspace,\n        userStorage,\n        lastMsgStorage,\n        channelStorage\n      )\n      this.clientMap.set(workspace, wsWorker)\n    }\n\n    await wsWorker.addUser(tgUser)\n  }\n\n  async getTarget ({ workspace, email }: User): Promise<[UserRecord, WorkspaceWorker | undefined]> {\n    const res = await this.storage.findOne({ email, workspace })\n\n    if (res === null) {\n      throw Error('User is not signed in')\n    }\n\n    return [res, this.clientMap.get(workspace)]\n  }\n\n  async removeUser (user: User): Promise<void> {\n    const [res, wsWorker] = await this.getTarget(user)\n\n    if (wsWorker === undefined) {\n      throw Error(`Invalid workspace: '${user.workspace}'`)\n    }\n\n    await wsWorker.removeUser({ phone: res.phone })\n  }\n\n  async getUserRecord ({ workspace, phone }: Pick<TgUser, 'workspace' | 'phone'>): Promise<UserRecord | undefined> {\n    return (await this.storage.findOne({ phone, workspace })) ?? undefined\n  }","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/services/telegram/pod-telegram/src/platform.ts#L36-L72","documentation":"getTarget resolves a platform User (email+workspace) to the stored UserRecord and workspace worker. If no record matches the email in that workspace, it throws 'User is not signed in' — the telegram integration only serves users who completed registration.","triggerScenarios":"Calling getTarget (from res/wsWorker message handling) with a User whose email has no stored record: the user never registered via the bot, registered in a different workspace, or their record was removed (removeUser/logout) while notifications still target them.","commonSituations":"Sending notifications to a user who signed out of the telegram integration, an email changed upstream but not re-registered, a wrong workspace id in the User payload, or storage cleared without revoking subscriptions.","solutions":["Ensure the user completed signup (addUser) for the exact workspace before targeting them.","Verify the email and workspace fields match the stored record (case/whitespace).","Handle the error upstream: skip the notification or prompt the user to reconnect the telegram integration.","If the user re-registered with a new email, update subscriptions to the new identity."],"exampleFix":"// before\nconst [user, worker] = await platform.getTarget(user)\n// after\ntry {\n  const [user, worker] = await platform.getTarget(user)\n} catch (err) {\n  if (err.message === 'User is not signed in') {\n    console.warn('Skipping telegram delivery: user not signed in', user.email)\n    return\n  }\n  throw err\n}","handlingStrategy":"try-catch","validationCode":"const signedIn = await storage.findOne({ email: user.email, workspace: user.workspace })\nif (signedIn === null) console.warn(`${user.email} has no telegram registration; getTarget will throw`)","typeGuard":"function isRegistered(record: UserRecord | null): record is UserRecord { return record !== null }","tryCatchPattern":"try {\n  const [record, worker] = await platform.getTarget(user)\n} catch (err) {\n  if (err.message === 'User is not signed in') {\n    console.warn('Telegram delivery skipped: user not signed in', user.email)\n    return // skip notification gracefully\n  }\n  throw err\n}","preventionTips":["Only send telegram notifications to users who completed bot registration.","Re-check registration after removeUser/logout flows.","Normalize email case/whitespace before lookup.","Ensure the same workspace id is used in both registration and targeting."],"tags":["auth","registration","telegram","lookup"],"backgroundTag":"user-not-signed-in","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}