Skip to content

fix(contributor-profile): prevent crashes on failed GitHub API responses#484

Merged
mehul-m-prajapati merged 1 commit into
GitMetricsLab:mainfrom
mayurigade-hub:fix/contributor-profile-api-error-handling
May 29, 2026
Merged

fix(contributor-profile): prevent crashes on failed GitHub API responses#484
mehul-m-prajapati merged 1 commit into
GitMetricsLab:mainfrom
mayurigade-hub:fix/contributor-profile-api-error-handling

Conversation

@mayurigade-hub
Copy link
Copy Markdown
Contributor

@mayurigade-hub mayurigade-hub commented May 24, 2026

Related Issue


Description

This PR fixes the contributor profile page crashing when GitHub API requests fail.

Changes made:

  • Added proper response.ok checks for GitHub API responses
  • Prevented crashes when GitHub rate limits API requests
  • Added safe fallback using prsData.items ?? []
  • Handled invalid GitHub usernames gracefully
  • Added toast error messages for failed API responses

This ensures the page no longer crashes and users receive proper feedback when API requests fail.


How Has This Been Tested?

  • Tested with valid GitHub usernames
  • Tested with invalid usernames
  • Tested API failure handling manually
  • Verified the page no longer crashes when PR data is unavailable

Screenshots (if applicable)

N/A — Backend/API handling fix, no major UI changes.


Type of Change

  • Bug fix
  • New feature
  • Code style update
  • Breaking change
  • Documentation update

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling for missing contributor profiles, now gracefully showing an empty state instead of crashing.
    • Pull request loading failures now display error notifications without disrupting the app.
    • Enhanced data validation to prevent crashes from unexpected response formats.

Review Change Stack

@netlify
Copy link
Copy Markdown

netlify Bot commented May 24, 2026

Deploy Preview for github-spy ready!

Name Link
🔨 Latest commit 99529aa
🔍 Latest deploy log https://app.netlify.com/projects/github-spy/deploys/6a12f54e5416c90007670cab
😎 Deploy Preview https://deploy-preview-484--github-spy.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 095dd1f5-cadf-46ba-ba90-29e43edf720a

📥 Commits

Reviewing files that changed from the base of the PR and between 6c6bc3e and 99529aa.

📒 Files selected for processing (1)
  • src/pages/ContributorProfile/ContributorProfile.tsx

📝 Walkthrough

Walkthrough

The ContributorProfile component's data-loading effect now validates GitHub API responses before using the returned data. The user fetch checks for 404 (indicating an invalid username) and other error statuses; the PR search request validates its response status and safely handles missing items. Error cases show appropriate feedback or fallbacks instead of crashing.

Changes

API Response Validation

Layer / File(s) Summary
API response validation and error handling
src/pages/ContributorProfile/ContributorProfile.tsx
User fetch adds ok check with 404 handling (sets profile to null, clears prs, returns early) and throws on other failures. PR fetch checks ok with error toast and empty list fallback; success uses prsData.items ?? [].

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

level2

Poem

A rabbit hops through GitHub's halls,
Where 404s and rate-limits call—
Now error checks catch each wrong response,
With graceful fallbacks, no more chance
For crashes when the API stalls! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: preventing crashes when GitHub API responses fail.
Description check ✅ Passed The description follows the template structure with all required sections completed, including related issue, detailed changes, testing approach, and type of change.
Linked Issues check ✅ Passed The PR fully addresses issue #461 by adding response.ok checks, handling 404 responses gracefully, preventing TypeError crashes with safe fallbacks, and adding toast error messages.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the contributor profile page's API error handling, with no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mehul-m-prajapati mehul-m-prajapati merged commit 103a153 into GitMetricsLab:main May 29, 2026
7 checks passed
@github-actions
Copy link
Copy Markdown

🎉🎉 Thank you for your contribution! Your PR #484 has been merged! 🎉🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Contributor profile page crashes when GitHub API fails or invalid username is used

2 participants