Budibase/budibase · error

Group not found

Error message

Group not found

What it means

remove(groupId, revision) fetches the group by id and, if db.groups.get throws for any reason (missing document, wrong id, DB access error), replaces the underlying error with a generic 'Group not found' Error. It is the SDK's guard so callers get a consistent signal that the group targeted for deletion does not exist.

Source

Thrown at packages/pro/src/sdk/groups/groups.ts:334

    if (newCreators > 0) {
      await quotas.addUsers(0, newCreators)
    } else if (newCreators < 0) {
      const creatorsCountAfterSave = await getCreatorsCountInGroup(group)
      const creatorsToRemove = Math.abs(newCreators) - creatorsCountAfterSave
      if (creatorsToRemove > 0) {
        await quotas.removeUsers(0, creatorsToRemove)
      }
    }
    return savedGroup
  }
}

export async function remove(groupId: string, revision: string) {
  let group
  try {
    group = await db.groups.get(groupId)
  } catch (err) {
    throw new Error("Group not found")
  }

  const isCreatorGroup = Object.values((group.roles || {}) as object).includes(
    "CREATOR"
  )
  let recalculateCreatorsQuotasFn: () => Promise<void> | void = () => {}
  if (isCreatorGroup) {
    const globalDb = tenancy.getGlobalDB()
    const usersInGroup = await db.groups.getGroupUsers(groupId)
    const users = await Promise.all(
      (usersInGroup as User[]).map(user => {
        return globalDb.get<User>(user._id)
      })
    )
    const usersWithoutGroup = users.map(user => ({
      ...user,
      userGroups: user.userGroups!.filter(grp => grp !== groupId),
    }))

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Verify the groupId is correct and the group still exists before deleting (fetch the group first).
  2. Handle the already-deleted case idempotently: catch the error and treat the group as removed if a second delete also reports not found.
  3. If removals cluster together, refresh the group list before retrying so stale ids are cleared.
  4. If the group exists but removal still fails, check DB connectivity — the generic message can mask underlying get() errors.

Example fix

// before
await groups.remove(groupId, revision) // throws 'Group not found'
// after
try {
  await groups.remove(groupId, revision)
} catch (err) {
  if (err.message === "Group not found") {
    // already deleted — treat as success / refresh list
  } else {
    throw err
  }
}
Defensive patterns

Strategy: try-catch

Validate before calling

let exists = true
try { await db.groups.get(groupId) } catch { exists = false }
if (!exists) { /* skip removal or refresh group list */ }

Try / catch

try {
  await groups.remove(groupId, revision)
} catch (err) {
  if (err.message === "Group not found") {
    // idempotent: treat as already deleted
  } else throw err
}

Prevention

When it happens

Trigger: Calling remove() with a groupId that does not exist, was already deleted, or whose document cannot be read from the groups DB (including any error thrown by get, e.g. connectivity problems that get masked as 'not found').

Common situations: UI/API acting on a stale group list after another admin deleted the group; wrong id passed from a client cache; double-submitting a delete; database outage misreported as a missing group.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29). Data as JSON: /api/errors/a7086e25dddd70fd. Report an issue: GitHub.