-
-
Notifications
You must be signed in to change notification settings - Fork 313
Fix ValueError on empty stake_amount/days_duration in pool creation #4678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
Co-authored-by: DonnieBLT <[email protected]>
|
@copilot I have attached the complete error of the ci/cd error. can you make a fix for that. |
|
@copilot I have attached the complete error of the ci/cd error. can you make a fix for that. |
I don't see the complete error details in your comment. Could you please paste the CI/CD error message here or let me know which specific workflow is failing (pre-commit, tests, or docker-test)? That will help me identify and fix the issue. |
|
here is the complete error |
|
@coderabbitai can you reolve this issue, the error in in the error.yaml file, the cicd is breaking with it. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 28211 🏁 Script executed: Length of output: 1598 🏁 Script executed: Length of output: 15012 🏁 Script executed: Length of output: 126 🏁 Script executed: Length of output: 10305 🏁 Script executed: Length of output: 3124 @mdkaifansari04, I've identified the issue! The CI/CD is failing because the leaderboard queries are including entries with empty usernames, which causes the template to fail when trying to generate profile URLs. The problem is in the Here's the fix: def get_context_data(self, *args, **kwargs):
"""
Assembles template context for the global leaderboard page, adding leaderboards and related data.
The context includes:
- `user_related_tags`: tags associated with user profiles.
- `wallet`: the requesting user's Wallet if authenticated.
- `leaderboard`: top users by total score (limited to 10).
- `pr_leaderboard`: top repositories/users by merged pull request count (top 10).
- `code_review_leaderboard`: top reviewers by review count (top 10).
- `top_visitors`: user profiles ordered by daily visit count (top 10).
Returns:
dict: Context mapping names (as listed above) to their querysets or values.
"""
context = super(GlobalLeaderboardView, self).get_context_data(*args, **kwargs)
user_related_tags = Tag.objects.filter(userprofile__isnull=False).distinct()
context["user_related_tags"] = user_related_tags
if self.request.user.is_authenticated:
context["wallet"] = Wallet.objects.get(user=self.request.user)
context["leaderboard"] = self.get_leaderboard()[:10] # Limit to 10 entries
# Pull Request Leaderboard - Filter out entries with null/empty usernames
pr_leaderboard = (
GitHubIssue.objects.filter(
type="pull_request",
is_merged=True,
user_profile__user__username__isnull=False
)
.exclude(user_profile__user__username="")
.values(
"user_profile__user__username",
"user_profile__user__email",
"user_profile__github_url",
)
.annotate(total_prs=Count("id"))
.order_by("-total_prs")[:10]
)
context["pr_leaderboard"] = pr_leaderboard
# Reviewed PR Leaderboard - Filter out entries with null/empty usernames
reviewed_pr_leaderboard = (
GitHubReview.objects.filter(
reviewer__user__username__isnull=False
)
.exclude(reviewer__user__username="")
.values(
"reviewer__user__username",
"reviewer__user__email",
"reviewer__github_url",
)
.annotate(total_reviews=Count("id"))
.order_by("-total_reviews")[:10]
)
context["code_review_leaderboard"] = reviewed_pr_leaderboard
# Top visitors leaderboard
top_visitors = (
UserProfile.objects.select_related("user")
.filter(daily_visit_count__gt=0)
.order_by("-daily_visit_count")[:10]
)
context["top_visitors"] = top_visitors
return contextThe key changes are:
These filters ensure that only entries with valid usernames are included in the leaderboards, preventing the Update the |
Fix ValueError on empty stake_amount/days_duration in pool creation
Fix ValueError on empty stake_amount/days_duration in pool creation
Creating a staking pool crashes with
ValueErrorwhenstake_amountordays_durationform fields are submitted empty.Root Cause
request.POST.get(key, default)only applies the default when the key is absent, not when the value is an empty string. Converting empty strings withDecimal("")orint("")raisesValueError.Changes
Handle empty/None values before type conversion:
The existing
ValueErrorhandler still catches invalid formats like"abc".✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.