Skip to content

Team invitations: inviteMember / acceptInvitation throw — users see the masked digest error instead of actionable messages #548

Closed

Description

@gkhngyk

Problem

Two server actions in web/src/lib/actions/team.ts throw on common, user-reachable failures. In production a thrown server action surfaces as the masked An error occurred in the Server Components render… digest: … string, so the actionable message is lost.

inviteMember throws:

  • Invalid email address
  • This user is already a member of your team
  • A pending invitation already exists for this email
  • Supabase insert errors

Repro: invite the same email twice from Settings → Team. The second attempt shows the digest string instead of "A pending invitation already exists for this email".

acceptInvitation throws:

  • Invitation not found / This invitation is no longer valid / This invitation has expired
  • This invitation was sent to ${inviteEmail}. Please sign in with that email.

Repro: open an invitation link while signed in with a different account. The user hits a dead end with a digest error instead of being told to switch accounts — the single most actionable message in the flow.

Fix

Follow the pattern from PR #536 (addPromptToBrand in web/src/lib/actions/prompt.ts is the in-repo reference implementation): return errors as values instead of throwing.

  1. inviteMember → return { inviteLink, emailSent } | { error: string }; branch on 'error' in result in handleSubmit of web/src/components/settings/team-section.tsx.
  2. acceptInvitation → extend its existing result type with { error: string } and render the error inline in web/src/components/team/accept-invitation-card.tsx (inline beats a toast here — the message tells the user what to do next).

Acceptance

  • Duplicate invite shows the pending-invitation message.
  • Accepting with the wrong account shows the "sign in with that email" message inline on the card.

Activity

  1. added
    bug
    good first issue
    on Jul 28, 2026
  2. arambu1a commented on Jul 30, 2026

    @arambu1a
    Contributor

    Hi @gkhngyk I'll work on this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions