Skip to content

Concurrent team-member invite requests can create duplicate membership records and return inconsistent results #497

@Ridanshi

Description

@Ridanshi

Summary

The team invitation workflow performs membership existence checks separately from membership creation.

Under concurrent requests, multiple invite operations targeting the same user can pass validation simultaneously and attempt to create duplicate memberships.

Affected Files

  • teamService.ts
  • team.ts

Root Cause

The invitation flow follows a check-then-create pattern.

Concurrent requests can both observe that no membership exists and then proceed to create records simultaneously.

The workflow lacks transactional enforcement or idempotent membership creation guarantees.

Reproduction

  1. Create a team.
  2. Send multiple invite requests simultaneously for the same target user.
  3. Observe invite processing.
  4. Inspect resulting membership records.
  5. Observe duplicate creation attempts or inconsistent API responses.

Expected Behavior

Repeated invites for the same user should be handled idempotently.

Actual Behavior

Concurrent requests can race and create inconsistent membership state.

Why This Is Difficult To Detect

Sequential testing behaves correctly.

The issue only appears under concurrent invite activity.

Production Impact

  • Duplicate memberships
  • Failed invitations
  • Inconsistent team state
  • Unexpected API errors

Suggested Fix

Introduce transactional membership creation or enforce uniqueness with safe retry behavior.

Severity

High

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions