Stirling-Tools/Stirling-PDF · error · Error

Default team not found

Error message

Default team not found

What it means

Thrown by TeamDetailsSection.handleRemoveMember when allTeams does not contain a team named 'Default'. The remove-member flow does not delete users; it reassigns them to the 'Default' team, so the Default team must exist. This is a data-integrity / configuration assumption, not a transient error.

Source

Thrown at frontend/editor/src/proprietary/components/shared/config/configSections/TeamDetailsSection.tsx:177

  const handleRemoveMember = async (user: User) => {
    if (
      !window.confirm(
        t(
          "workspace.teams.confirmRemove",
          `Remove ${user.username} from this team?`,
        ),
      )
    ) {
      return;
    }

    try {
      setProcessing(true);
      // Find the Default team ID
      const defaultTeam = allTeams.find((t) => t.name === "Default");

      if (!defaultTeam) {
        throw new Error("Default team not found");
      }

      // Move user to Default team by updating their role with the Default team ID
      await teamService.moveUserToTeam(
        user.username,
        user.rolesAsString || "ROLE_USER",
        defaultTeam.id,
      );
      alert({
        alertType: "success",
        title: t(
          "workspace.teams.removeMemberSuccess",
          "User removed from team",
        ),
      });
      fetchTeamDetails();
    } catch (error: unknown) {
      console.error("Failed to remove member:", error);

View on GitHub (pinned to 9ef20dcab8)

Solutions

  1. Ensure allTeams is loaded (non-empty) before enabling the Remove Member action.
  2. Make the fallback team name configurable or use a stable team ID/type rather than a display name.
  3. If the Default team is genuinely missing, show a clear message instructing an admin to create it.

Example fix

// before
const defaultTeam = allTeams.find((t) => t.name === "Default");
if (!defaultTeam) {
  throw new Error("Default team not found");
}

// after
const defaultTeam = allTeams.find((t) => t.name === "Default");
if (!defaultTeam) {
  alert({
    alertType: "error",
    title: t("workspace.teams.defaultMissing", "The Default team does not exist. An admin must create it before members can be removed."),
  });
  return;
}
Defensive patterns

Strategy: validation

Validate before calling

// Ensure teams are loaded and Default exists before enabling Remove
const defaultTeam = allTeams.find((t) => t.name === "Default");
if (!defaultTeam) {
  alert({ alertType: "error", title: "The Default team is missing." });
  return;
}

Type guard

function hasDefaultTeam(teams: { name: string }[]): boolean {
  return teams.some((t) => t.name === "Default");
}

Prevention

When it happens

Trigger: The workspace has no team named exactly 'Default'. The team list (allTeams) is empty (not yet loaded). The 'Default' team was renamed or deleted by an admin.

Common situations: Fresh workspace where the Default team was not seeded. allTeams not loaded yet (async fetch pending) when the user clicks Remove. Admin renamed the Default team.

Related errors


AI-assisted analysis of Stirling-Tools/Stirling-PDF@9ef20dcab8 (2026-08-13). Data as JSON: /api/errors/713ce48e1de5859b. Report an issue: GitHub.