Skip to content

Comments

Add validation to prevent joining non-existent groups#4

Draft
Copilot wants to merge 2 commits intocreate-groupfrom
copilot/sub-pr-1-another-one
Draft

Add validation to prevent joining non-existent groups#4
Copilot wants to merge 2 commits intocreate-groupfrom
copilot/sub-pr-1-another-one

Conversation

Copy link

Copilot AI commented Nov 15, 2025

Addresses missing validation in handleJoinGroup that allowed users to join non-existent group codes, creating invalid empty group entries.

Changes

  • Group existence check: Validate group exists in database before allowing join
  • Group validity check: Verify group has either meta information or at least one member
  • Error handling: Return early with descriptive alerts on validation failure
// Validate that the group exists before joining
try {
    const groupSnap = await database.ref(`groups/${code}`).once('value');
    if (!groupSnap.exists()) {
        alert('Group code does not exist. Please check the code or create a new group.');
        return;
    }
    
    // Check if group has meta information or at least one member
    const metaSnap = await database.ref(`groups/${code}/meta`).once('value');
    const membersSnap = await database.ref(`groups/${code}/members`).once('value');
    
    if (!metaSnap.exists() && !membersSnap.exists()) {
        alert('This group appears to be invalid. Please create a new group or use a different code.');
        return;
    }
} catch (e) {
    console.error('Error validating group:', e);
    alert('Error validating group. Please try again.');
    return;
}

Fixes #1 (comment)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: kelliherm <63371331+kelliherm@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP on addressing feedback for group creation Add validation to prevent joining non-existent groups Nov 15, 2025
Copilot AI requested a review from kelliherm November 15, 2025 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants