{"record":{"id":"5296868a903766c6","repo":"hcengineering/platform","slug":"workspacelimitreached","errorCode":"WorkspaceLimitReached","errorMessage":"created-by-limit","messagePattern":"created-by-limit","errorType":"exception","errorClass":"PlatformError","httpStatus":null,"severity":"error","filePath":"server/account/src/operations.ts","lineNumber":602,"sourceCode":"\n  if (socialId == null) {\n    throw new PlatformError(new Status(Severity.ERROR, platform.status.AccountNotConfirmed, {}))\n  }\n  const person = await db.person.findOne({ uuid: socialId.personUuid })\n  if (person == null) {\n    throw new PlatformError(new Status(Severity.ERROR, platform.status.InternalServerError, {}))\n  }\n\n  const accountObj = await db.account.findOne({ uuid: account })\n  if (accountObj == null) {\n    throw new PlatformError(new Status(Severity.ERROR, platform.status.InternalServerError, {}))\n  }\n\n  // Get a list of created workspaces\n  const created = (await db.workspace.find({ createdBy: socialId.personUuid })).length\n\n  if (created >= (accountObj.maxWorkspaces ?? workspaceLimitPerUser)) {\n    ctx.warn('created-by-limit', { person: socialId.key, workspace: workspaceName })\n    throw new PlatformError(\n      new Status(Severity.ERROR, platform.status.WorkspaceLimitReached, { workspace: workspaceName })\n    )\n  }\n\n  // Persist the client-provided configuration as-is. The only currently\n  // supported field is `withDemoContent`; future fields can be added without\n  // changing the wire shape.\n  const pendingConfiguration =\n    configuration?.withDemoContent !== undefined ? { withDemoContent: configuration.withDemoContent } : undefined\n\n  const { workspaceUuid, workspaceUrl } = await createWorkspaceRecord(\n    ctx,\n    db,\n    branding,\n    workspaceName,\n    account,\n    region,","sourceCodeStart":584,"sourceCodeEnd":620,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/server/account/src/operations.ts#L584-L620","documentation":"createWorkspace enforces a per-user workspace quota: the number of workspaces created by the person (maxWorkspaces on the account, falling back to workspaceLimitPerUser) must not be exceeded. Exceeding it throws WorkspaceLimitReached with the workspace name.","triggerScenarios":"Calling createWorkspace when the requesting person already created >= maxWorkspaces (or the default workspaceLimitPerUser) workspaces, counted via db.workspace.find({ createdBy: personUuid }).","commonSituations":"Free-tier users hitting the workspace cap; test scripts creating many workspaces in a loop; an admin lowering maxWorkspaces below the user's current count; automated provisioning exceeding quota.","solutions":["Delete unused workspaces created by the user to get under the limit.","Ask an admin to raise maxWorkspaces on the account.","In automation, check the count of created workspaces before calling createWorkspace and stop at the quota.","Catch WorkspaceLimitReached in the UI and present an upgrade request path."],"exampleFix":"// before\nconst ws = await client.createWorkspace(workspaceName) // throws at limit\n// after\nconst mine = await getWorkspacesCreatedBy(me)\nconst limit = account.maxWorkspaces ?? DEFAULT_LIMIT\nif (mine.length >= limit) throw new UpgradeRequiredError()\nconst ws = await client.createWorkspace(workspaceName)","handlingStrategy":"validation","validationCode":"const created = await getWorkspacesCreatedBy(personUuid)\nconst limit = account.maxWorkspaces ?? DEFAULT_WORKSPACE_LIMIT\nif (created.length >= limit) throw new WorkspaceLimitError(limit)","typeGuard":"function isWorkspaceLimitReached(e: unknown): boolean {\n  return e instanceof PlatformError && e.status.code === platform.status.WorkspaceLimitReached\n}","tryCatchPattern":"try {\n  await client.createWorkspace(name)\n} catch (e) {\n  if (isWorkspaceLimitReached(e)) {\n    promptUpgrade()\n    return\n  }\n  throw e\n}","preventionTips":["Cache the current workspace count and check it before creating new workspaces.","Cap automated/test workspace creation loops.","Catch WorkspaceLimitReached in UIs and offer an upgrade path."],"tags":["workspace","quota","limit-exceeded"],"backgroundTag":"workspace-limit-reached","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}