{"record":{"id":"3b5de083827a1092","repo":"hcengineering/platform","slug":"workspacenotfound","errorCode":"WorkspaceNotFound","errorMessage":"platform.status.WorkspaceNotFound","messagePattern":"platform\\.status\\.WorkspaceNotFound","errorType":"error_code","errorClass":"PlatformError","httpStatus":null,"severity":"error","filePath":"server/account/src/operations.ts","lineNumber":2038,"sourceCode":"\n  if (!skipAssignmentCheck) {\n    let role = await db.getWorkspaceRole(account, workspaceUuid)\n    if (role === null && isAdmin) {\n      role = AccountRole.Admin\n    }\n\n    if (role == null) {\n      ctx.warn('Not a member of the workspace', { workspaceUuid, account })\n      throw new PlatformError(new Status(Severity.ERROR, platform.status.Forbidden, {}))\n    }\n  }\n\n  const workspace = await getWorkspaceInfoWithStatusById(db, workspaceUuid)\n\n  // TODO: what should we return for archived?\n  if (workspace == null) {\n    ctx.warn('Workspace not found', { workspaceUuid, account })\n    throw new PlatformError(new Status(Severity.ERROR, platform.status.WorkspaceNotFound, { workspaceUuid }))\n  }\n\n  if (workspace.status.isDisabled && isActiveMode(workspace.status.mode)) {\n    ctx.warn('Workspace is disabled', { workspaceUuid, account })\n    throw new PlatformError(new Status(Severity.ERROR, platform.status.WorkspaceNotFound, { workspaceUuid }))\n  }\n\n  if (!isGuest && updateLastVisit && !isAdmin) {\n    await db.workspaceStatus.update({ workspaceUuid }, { lastVisit: Date.now() })\n  }\n\n  return workspace\n}\n\n/**\n * Validates the token and returns the decoded account information.\n */\nexport async function getLoginInfoByToken (","sourceCodeStart":2020,"sourceCodeEnd":2056,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/server/account/src/operations.ts#L2020-L2056","documentation":"PlatformError with status WorkspaceNotFound thrown when the requested workspace does not exist or is disabled. getWorkspaceInfoWithStatusById returns null for an unknown uuid, and an existing workspace that is disabled while in an active mode is treated the same way, with the workspaceUuid included in the status data.","triggerScenarios":"Requesting a workspaceUuid that was deleted/never existed, or one whose status.isDisabled is true while isActiveMode(mode) holds — i.e. an admin-disabled workspace still nominally in active mode.","commonSituations":"Client cached a workspace id after deletion; workspace archived/deleted by an owner; workspace suspended by admins; typo in the uuid or hard-coded id from another environment.","solutions":["Verify the workspaceUuid is valid and still exists (fetch the user's workspace list)","Check with the workspace admin whether the workspace was disabled and request re-enablement","Remove stale references to deleted workspaces from client state","Handle WorkspaceNotFound in the client by redirecting to workspace selection"],"exampleFix":"// before\nconst info = await client.getWorkspaceInfo(token, { workspaceUuid: cachedUuid })\n// after\ntry {\n  const info = await client.getWorkspaceInfo(token, { workspaceUuid: cachedUuid })\n} catch (e) {\n  if (getPlatformStatusCode(e) === platform.status.WorkspaceNotFound) {\n    await reselectWorkspace() // drop stale id, pick from fresh list\n  } else throw e\n}","handlingStrategy":"try-catch","validationCode":"// confirm the workspace still exists in the user's accessible list before the call\nconst list = await client.getWorkspaces(token)\nif (!list.some(w => w.uuid === workspaceUuid)) {\n  throw new Error(`Workspace ${workspaceUuid} no longer exists or is inaccessible`)\n}","typeGuard":"function workspaceExists(w: { uuid: WorkspaceUuid } | null | undefined, id: WorkspaceUuid): w is { uuid: WorkspaceUuid } {\n  return w != null && w.uuid === id\n}","tryCatchPattern":"try {\n  const info = await client.getWorkspaceInfo(token, { workspaceUuid })\n} catch (e) {\n  if (getPlatformStatusCode(e) === platform.status.WorkspaceNotFound) {\n    await purgeStaleWorkspaceAndReselect(workspaceUuid) // deleted or disabled\n  } else throw e\n}","preventionTips":["Purge cached workspace ids after delete/archive events (webhooks or refetch)","Surface 'workspace disabled' states to users instead of retrying","Never hardcode workspace UUIDs; resolve them from an API listing","Match environment when copying ids between staging and production"],"tags":["workspace-not-found","resource-missing","workspace-lifecycle"],"backgroundTag":"workspace-not-found","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}