{"record":{"id":"88cff28548cc37c6","repo":"hcengineering/platform","slug":"cannot-find-current-person","errorCode":null,"errorMessage":"Cannot find current person","messagePattern":"Cannot find current person","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/love-resources/src/loveClient.ts","lineNumber":88,"sourceCode":"\n  private getLoveEndpoint (): string {\n    const endpoint = getMetadata(love.metadata.ServiceEnpdoint)\n    if (endpoint === undefined) {\n      throw new Error('Love service endpoint not found')\n    }\n\n    return endpoint\n  }\n\n  private async refreshRoomToken (room: Room): Promise<string> {\n    const sessionName = this.getTokenRoomName(room)\n    const endpoint = this.getLoveEndpoint()\n    if (endpoint === undefined) {\n      throw new Error('Love service endpoint not found')\n    }\n    const myPerson = await getPersonByPersonRef(getCurrentEmployee())\n    if (myPerson == null) {\n      throw new Error('Cannot find current person')\n    }\n    const platformToken = getPlatformToken()\n    const res = await fetch(concatLink(endpoint, '/getToken'), {\n      method: 'POST',\n      headers: {\n        Authorization: `Bearer ${platformToken}`,\n        'Content-Type': 'application/json'\n      },\n      body: JSON.stringify({ roomName: sessionName, _id: myPerson._id, participantName: myPerson.name })\n    })\n    return await res.text()\n  }\n\n  private getTokenRoomName (room: Room): string {\n    const currentWorkspaceUuid = getMetadata(presentation.metadata.WorkspaceUuid)\n    if (currentWorkspaceUuid === undefined) {\n      throw new Error('Current workspace not found')\n    }","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/plugins/love-resources/src/loveClient.ts#L70-L106","documentation":"refreshRoomToken calls getPersonByPersonRef(getCurrentEmployee()) to identify the user asking for a room token. If that lookup returns null — the current employee's person record cannot be resolved — the client refuses to continue and throws, because the Love service needs a valid person identity to mint tokens. This runs after the endpoint check, so the endpoint was fine but the user identity resolution failed.","triggerScenarios":"getRoomToken -> refreshRoomToken while getCurrentEmployee() returns a ref that does not resolve to a Person via getPersonByPersonRef (returns null): the logged-in employee account has no linked Person record, or the employee reference is unset/stale.","commonSituations":"User session is stale or logged out when the call room token refresh happens; guest/limited account without a Person record joins a love room; employee data not yet synchronized after account creation; person record deleted while session persists.","solutions":["Re-login / refresh the session so getCurrentEmployee() returns a valid employee linked to a Person record.","Verify the account has a properly linked Person record; create or repair the employee-to-person link in the database.","Delay room-token refresh until user data is fully loaded (wait for account/person initialization before joining rooms).","Catch the error client-side and prompt the user to reload or re-authenticate before retrying the call."],"exampleFix":"// before\nconst token = await client.getRoomToken(room)\n// after\ntry {\n  const token = await client.getRoomToken(room)\n} catch (err) {\n  if (err.message === 'Cannot find current person') {\n    console.warn('User identity not ready; re-authenticating before joining room')\n    await relogin()\n    return await client.getRoomToken(room)\n  }\n  throw err\n}","handlingStrategy":"try-catch","validationCode":"const myPerson = await getPersonByPersonRef(getCurrentEmployee())\nif (myPerson == null) {\n  console.warn('Current person not resolvable; re-authentication needed')\n  return\n}","typeGuard":"function hasPerson (p: Person | null | undefined): p is Person {\n  return p != null\n}","tryCatchPattern":"try {\n  const token = await client.getRoomToken(room)\n} catch (err) {\n  if (err.message === 'Cannot find current person') {\n    await relogin()\n    return await client.getRoomToken(room)\n  }\n  throw err\n}","preventionTips":["Only join/refresh call rooms after user and person data are fully loaded.","Re-authenticate on session expiry before making service calls.","Ensure every employee account has a linked Person record.","Handle guest/limited accounts explicitly instead of letting them hit token refresh."],"tags":["authentication","identity","session","user-lookup"],"backgroundTag":"user-identity-not-found","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}