{"record":{"id":"7f162a3ca9ab4570","repo":"hcengineering/platform","slug":"current-workspace-not-found","errorCode":null,"errorMessage":"Current workspace not found","messagePattern":"Current workspace not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/love-resources/src/loveClient.ts","lineNumber":105,"sourceCode":"    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    }\n    return `${currentWorkspaceUuid}_${room.name}_${room._id}`\n  }\n}\n","sourceCodeStart":87,"sourceCodeEnd":110,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/plugins/love-resources/src/loveClient.ts#L87-L110","documentation":"getTokenRoomName builds the room name as `${workspaceUuid}_${room.name}_${room._id}` using the WorkspaceUuid client metadata (presentation.metadata.WorkspaceUuid). If that metadata is undefined the client cannot namespace the room to a workspace, so it throws before constructing the name. This guard prevents tokens/rooms from being created without a workspace scope.","triggerScenarios":"Any path that needs a room name (roomName getter or refreshRoomToken's sessionName) runs while presentation.metadata.WorkspaceUuid is undefined — workspace metadata not yet loaded or never set.","commonSituations":"Client initialized before workspace selection/bootstrap completed; embedded usage where workspace metadata is not injected; misconfigured deployment where the workspace UUID is missing from the presentation config; race where love client is constructed before workspace metadata arrives.","solutions":["Ensure the workspace is fully initialized (workspace UUID set in presentation metadata) before creating the LoveClient or joining rooms.","Reload the client so workspace metadata is re-fetched after login/workspace selection.","Check the deployment/bootstrap config to confirm the workspace UUID is published to the client.","Defer love-room operations behind a check: only call room APIs once getMetadata(presentation.metadata.WorkspaceUuid) is defined."],"exampleFix":"// before\nconst name = client.getRoomToken(room) // throws 'Current workspace not found'\n// after\nconst wsUuid = getMetadata(presentation.metadata.WorkspaceUuid)\nif (wsUuid === undefined) {\n  console.warn('Workspace not ready; postponing room join')\n} else {\n  const token = await client.getRoomToken(room)\n}","handlingStrategy":"validation","validationCode":"const wsUuid = getMetadata(presentation.metadata.WorkspaceUuid)\nif (wsUuid === undefined) {\n  console.warn('Workspace metadata not ready; deferring room join')\n  return\n}","typeGuard":"function hasWorkspace (uuid: string | undefined): uuid is string {\n  return typeof uuid === 'string' && uuid.length > 0\n}","tryCatchPattern":"try {\n  const token = await client.getRoomToken(room)\n} catch (err) {\n  if (err.message === 'Current workspace not found') {\n    console.warn('Workspace not initialized; cannot join room yet')\n    return null\n  }\n  throw err\n}","preventionTips":["Initialize the LoveClient only after workspace selection/bootstrap completes.","Check presentation.metadata.WorkspaceUuid before any room-name operation.","Avoid constructing love rooms in contexts without workspace metadata (e.g. pre-login screens).","Add an init-order test that exercises room join right after workspace load."],"tags":["configuration","missing-metadata","workspace","initialization-order"],"backgroundTag":"missing-metadata","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}