Skip to content

[BUG] WorkspaceInvitation model stores workspace_name string instead of workspace_id foreign key; accept_invitation endpoint never implemented #737

Description

@vipul674

Description of the Bug

The workspace invitation system has two related bugs that make it non-functional:

Bug 1: WorkspaceInvitation model uses workspace_name instead of workspace_id

In backend/app/models.py, the WorkspaceInvitation model stores workspace_name: str rather than a workspace_id foreign key. When an invitation is accepted, there is no way to reliably look up the actual workspace because:

  • The workspace could have been renamed since the invitation was created
  • The workspace could have been deleted
  • Multiple workspaces could share the same name
  • There is no database constraint enforcing referential integrity

Bug 2: accept_invitation endpoint does not exist

Looking at backend/app/routes/workspaces.py and the FastAPI router includes in main.py, there is no accept_invitation endpoint. Even if invitations could be sent (see Bug #736), there is no way for the invited user to accept them. The invitation feature is half-implemented - it supports creating invitations but not consuming them.

Steps to Reproduce

  1. As a user, receive a workspace invitation link (however it's delivered)
  2. There is no API endpoint to accept the invitation
  3. The invitation feature is non-functional end-to-end

Expected Behavior

  1. WorkspaceInvitation model should have a workspace_id foreign key pointing to the Workspace table
  2. There must be a POST /api/v1/workspaces/invitations/{invitation_id}/accept endpoint
  3. Accepting an invitation should add the user as a member of the workspace

Affected Files

  • backend/app/models.py (WorkspaceInvitation model)
  • backend/app/routes/workspaces.py (missing accept_invitation endpoint)

Suggested Fix

  1. Add workspace_id: Mapped[str] = mapped_column(ForeignKey("workspaces.id")) to WorkspaceInvitation
  2. Implement an acceptance endpoint that validates the invitation token, finds the workspace, creates a WorkspaceMember record, and marks the invitation as accepted

GSSoC '26

  • Yes, I am participating in GirlScript Summer of Code and would like to fix this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    gssocGirlScript Summer of Code 2026 issue/PR

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions