Skip to content

fix: config key mismatch and safe Guid parsing in backend controllers#24

Merged
jaseel0 merged 2 commits intobackendfrom
copilot/sub-pr-22
Mar 15, 2026
Merged

fix: config key mismatch and safe Guid parsing in backend controllers#24
jaseel0 merged 2 commits intobackendfrom
copilot/sub-pr-22

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 15, 2026

Two OAuth token exchange endpoints were silently broken due to a config key mismatch, and Guid.Parse across IssuesController would throw unhandled 500s on malformed JWT claims.

Changes

Config key mismatch (GitHub:RedirectUriGitHub:CallbackUrl)

  • AuthController.cs and GitHubService.cs both read GitHub:RedirectUri, which is not defined in appsettings.json — the actual key is GitHub:CallbackUrl. This caused OAuth token exchange to always send an empty redirect_uri.

Defensive Guid parsing in IssuesController

  • Replaced Guid.Parse with Guid.TryParse in ClaimQuest, GetMyQuests, and SubmitQuest — a malformed claim now returns 401 instead of throwing a FormatException.
  • Standardized error messages across all three endpoints for consistency.
// Before — throws FormatException on bad claim
var userId = Guid.Parse(userIdClaim);

// After — returns 401 gracefully
if (!Guid.TryParse(userIdClaim, out var userId))
    return Unauthorized("Invalid user ID in token.");

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…id.TryParse

Co-authored-by: jaseel0 <225665919+jaseel0@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix backend authentication and database integration issues fix: config key mismatch and safe Guid parsing in backend controllers Mar 15, 2026
Copilot AI requested a review from jaseel0 March 15, 2026 13:46
@naheel0 naheel0 marked this pull request as ready for review March 15, 2026 13:49
@github-actions github-actions bot added the configuration Configuration file changes label Mar 15, 2026
@jaseel0 jaseel0 merged commit 9b19beb into backend Mar 15, 2026
6 checks passed
@jaseel0 jaseel0 deleted the copilot/sub-pr-22 branch March 15, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

configuration Configuration file changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants