Repository navigation
fix: handle missing name fields and GitHub API errors in social auth - #173
Conversation
🔍 Existing Issues For ReviewYour pull request is modifying functions with the following pre-existing issues: 📄 File: backend/user/services.py
|
PR Compliance Guide 🔍(Compliance updated until commit 80e7d32)Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label Previous compliance checksCompliance check up to commit 404ef29
Compliance check up to commit 404ef29
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||
Co-authored-by: qodo-merge-pro[bot] <151058649+qodo-merge-pro[bot]@users.noreply.github.com>
User description
Description
Fixes BACKEND-P. The issue was that: GitHub OAuth response with 200 status and error payload causes KeyError: 'access_token' due to missing key validation.
.get()when accessinggiven_nameandfamily_namefrom the API response, preventing errors when these fields are missing.errorkey in the response body and to ensure that theaccess_tokenis present before proceeding.This fix was generated by Seer in Sentry, triggered by AmirMohsen Asaran Ghomi. 👁️ Run ID: 43128
Not quite right? Click here to continue debugging with Seer.
Related Issue
Fixes BACKEND-P
Type of Change
UI Changes
Checklist
Auto-created Ticket
#178
PR Type
Bug fix
Description
Add error handling for GitHub OAuth response with error payload
Use
.get()for optional name fields in Google/Facebook authPrevent KeyError when accessing missing API response fields
Validate access_token presence before GitHub API calls
Diagram Walkthrough
flowchart LR A["Social Auth Response"] --> B{"Check for errors"} B -->|Error present| C["Return None"] B -->|No error| D{"Validate required fields"} D -->|Missing fields| E["Return None"] D -->|Fields present| F["Create/Get User"]File Walkthrough
services.py
Add error handling and safe field access in OAuthbackend/user/services.py
.get()for optionalgiven_nameandfamily_namefields.get()for optionalgiven_nameandfamily_namefieldsresponses
access_tokenexists before using it inGitHub API calls