Bug Description
The get_codeforces_submission_stats method and get_leetcode_data make external API calls with no timeout and no error handling, causing the entire endpoint to crash on network failures.
Affected Code
# views.py, line 259 - NO TIMEOUT
url = f"https://codeforces.com/api/user.status?handle={username}"
response = requests.get(url) # Will hang forever if server doesn't respond
# views.py, line 463-464 - NO TIMEOUT, NO ERROR HANDLING
url = f"https://alfa-leetcode-api.onrender.com/userProfile/{username}"
response = requests.get(url)
if response.status_code == 200:
data = response.json() # If not 200, returns None implicitly
Impact
- If Codeforces API hangs, the page never loads (no timeout set)
- If LeetCode API returns 500/503,
get_leetcode_data() returns None, causing KeyError when the caller does user_data["ranking"]
- The onrender.com LeetCode proxy is on a free tier and frequently sleeps
Expected Behavior
- All
requests.get() calls should use timeout=30 to prevent hanging
- The LeetCode endpoint should check if
user_data is None before returning
Bug Description
The
get_codeforces_submission_statsmethod andget_leetcode_datamake external API calls with no timeout and no error handling, causing the entire endpoint to crash on network failures.Affected Code
Impact
get_leetcode_data()returnsNone, causingKeyErrorwhen the caller doesuser_data["ranking"]Expected Behavior
requests.get()calls should usetimeout=30to prevent hanginguser_data is Nonebefore returning