What is happening?
The /contributor/:username page is not properly handling failed GitHub API responses.
Because of this, two related issues happen:
1. Page crashes when GitHub rate limit is exceeded
When GitHub blocks too many requests, the API returns an error response instead of PR data.
Current code directly does:
If items is missing, the page crashes with a TypeError.
2. Invalid usernames show a broken page
When visiting a non-existent GitHub username, GitHub returns a 404 response.
But the code still stores the error object as profile data instead of showing a proper error message.
As a result:
- empty avatar
- broken profile section
- no "User not found" message
Why is this a problem?
The page assumes every GitHub API request is successful.
But fetch() does not automatically throw errors for failed responses like:
403 (rate limit exceeded)
404 (user not found)
Because of missing response checks:
- the page crashes
- invalid users render broken UI
- users do not get proper feedback
How to fix it?
Before using API data, check if the response is successful using response.ok.
Example:
if (!userRes.ok) {
throw new Error("User not found");
}
if (!prsRes.ok) {
throw new Error("Failed to load pull requests");
}
setPRs(prsData.items ?? []);
This will:
- prevent crashes
- safely handle failed API responses
- show proper error messages to users
Steps to Reproduce
Bug 1
- Open contributor profile pages multiple times quickly
- Trigger GitHub API rate limit
- Notice the page crashes
Bug 2
- Visit:
/contributor/thisisnotreal99999
- Observe broken empty profile page instead of proper error message
File Affected
src/pages/ContributorProfile/ContributorProfile.tsx
What is happening?
The
/contributor/:usernamepage is not properly handling failed GitHub API responses.Because of this, two related issues happen:
1. Page crashes when GitHub rate limit is exceeded
When GitHub blocks too many requests, the API returns an error response instead of PR data.
Current code directly does:
If
itemsis missing, the page crashes with a TypeError.2. Invalid usernames show a broken page
When visiting a non-existent GitHub username, GitHub returns a
404response.But the code still stores the error object as profile data instead of showing a proper error message.
As a result:
Why is this a problem?
The page assumes every GitHub API request is successful.
But
fetch()does not automatically throw errors for failed responses like:403(rate limit exceeded)404(user not found)Because of missing response checks:
How to fix it?
Before using API data, check if the response is successful using
response.ok.Example:
This will:
Steps to Reproduce
Bug 1
Bug 2
File Affected