fix: division by zero in leaderboard calculation#29
fix: division by zero in leaderboard calculation#29mohansinghi wants to merge 1 commit intoPlatformNetwork:mainfrom
Conversation
📝 WalkthroughWalkthroughUpdated Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✏️ Tip: You can disable this entire section by setting Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Add defensive check for empty scores vector before division to prevent potential panic. While evaluations.is_empty() is checked above, this adds an extra layer of safety in case the mapping produces an empty vector. Fixes division by zero bug in update_leaderboard function.
a3bfd39 to
e165d4c
Compare
|
@echobt Could you please review my pr? |
Summary
Division by Zero in Leaderboard Calculation
Severity: Medium
File:
crates/platform-server/src/db/queries.rs:341Effort: Small (4 lines)
Current - can panic if scores vector is empty:
Impact: When scores vector is empty, division by zero causes panic and crashes the leaderboard update endpoint.
Fix: Add defensive check before division:
Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=158349177
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.