fix(backend): address all CodeRabbit security and correctness issues#23
Merged
fix(backend): address all CodeRabbit security and correctness issues#23
Conversation
Co-authored-by: jaseel0 <225665919+jaseel0@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add authentication and database integration for backend
fix(backend): address all CodeRabbit security and correctness issues
Mar 15, 2026
naheel0
approved these changes
Mar 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves a set of critical and major issues flagged by CodeRabbit on the initial backend implementation, spanning hardcoded secrets, resource leaks, race conditions, and flawed game logic.
Security
JwtSettings:Key,GitHub:ClientSecret, andGitHub:ClientIdfromappsettings.json; replaced with empty placeholders. Values must be supplied via environment variables or user-secrets.Program.csnow throwsInvalidOperationExceptionat startup instead of silently using a known fallback key.Resource & Error Handling
IDisposableleaks:HttpRequestMessageinstances inAuthControllerandGitHubServicenow useusing var.SendAsync/ReadFromJsonAsyncin try-catch; addedIsSuccessStatusCodeguard before deserialization.GitHubService.GetAccessToken, theAccept: application/jsonheader is now set on the request beforeSendAsync(previously set on the shared client after the request had already been sent).Game Logic & Data Integrity
claimnow validates the issue exists andIsActivein the database;submitderives the reward fromIssue.XPRewardrather than a hardcoded30.(UserId, GitHubIssueId) WHERE Status='In Progress'via a new migration;SaveChangesAsyncis wrapped to return409 Conflicton key violation.CurrentStreak += 1on every submit with date-aware logic usingLastContributionDate— extends on consecutive days, resets on gaps, no-ops on same-day resubmits.my-active-questswas returning all quests for a user; now filters toStatus == "In Progress"only.Schema
GitHubIduniqueness: Added unique index onUsers.GitHubId(the stable external identity) in the newAddUniqueConstraintsmigration, alongside the filtered quest index above.8.0.*wildcard versions to8.0.13for all EF Core and JWT packages.API Shape
GET /users/profile/{username}now returns a projected DTO instead of the raw EF entity graph, avoiding circular reference issues and inadvertent data exposure.StringComparison.OrdinalIgnoreCase.GitHubIssueItem.Body: Made nullable (string?) to match GitHub API behaviour for empty issue bodies.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.