Skip to content

fix(leaderboardUtils): add null guard for username in buildRanksMap to prevent silent collisions #77

Description

@tmdeveloper007

Summary of What Needs to be Done

Add a null/undefined guard for c.username in the buildRanksMap function in src/utils/leaderboardUtils.js. The function directly accesses c.username as a Map key without checking for null/undefined. If a contributor object has a null or undefined username, the map key becomes null/undefined, causing silent rank collisions where multiple contributors overwrite each other's slot.

Changes

In buildRanksMap, add a guard if (!c?.username) return to skip entries without a valid username. This prevents null-key collisions and ensures the rank map only contains valid contributor entries.

Impact

Severity: Low — Silent data corruption in leaderboard ranking. Rank display may show incorrect positions if any contributor has a null/undefined username. No crash, but incorrect rankings could mislead users.

Please assign this task to me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    gssoc:approvedApproved for GSSoC contributionlevel:beginnerSmall, low-risk change (≤3 files, ≤50 lines)type:bugSomething is broken or incorrect

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions