Skip to content

missing HTTP response validation in the profile fetch logic#647

Open
annrose2277-glitch wants to merge 1 commit into
GitMetricsLab:mainfrom
annrose2277-glitch:bug
Open

missing HTTP response validation in the profile fetch logic#647
annrose2277-glitch wants to merge 1 commit into
GitMetricsLab:mainfrom
annrose2277-glitch:bug

Conversation

@annrose2277-glitch
Copy link
Copy Markdown

@annrose2277-glitch annrose2277-glitch commented Jun 1, 2026

Related Issue


Description

This PR fixes a critical bug where the application would silently fail or crash if the GitHub API returned a non-200 response (like a 404 for a missing user). Added an if (userRes.ok) check to validate the HTTP response status before attempting to parse the JSON.


How Has This Been Tested?

  • Ran the local development server.
  • Searched for a valid GitHub username to ensure the profile still loads correctly.
  • Searched for an invalid/non-existent GitHub username to verify the app gracefully handles the error instead of crashing.

Type of Change

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

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling for GitHub user profile data retrieval to ensure users receive proper error notifications when the request fails.

@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 1, 2026

Deploy Preview for github-spy ready!

Name Link
🔨 Latest commit fece837
🔍 Latest deploy log https://app.netlify.com/projects/github-spy/deploys/6a1d000b7c145400084128b2
😎 Deploy Preview https://deploy-preview-647--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 Jun 1, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 91aa0ee0-7930-4148-8de8-261023e63216

📥 Commits

Reviewing files that changed from the base of the PR and between 53f820b and fece837.

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

📝 Walkthrough

Walkthrough

The PR improves HTTP status handling in the GitHub user fetch by adding an explicit ok check before parsing the response, allowing the existing error catch path to handle non-OK responses.

Changes

HTTP Status Check

Layer / File(s) Summary
Response status guard for GitHub user fetch
src/pages/ContributorProfile/ContributorProfile.tsx
GitHub user fetch now explicitly checks userRes.ok and throws an error on non-OK responses, triggering the existing catch path for error toast and loading state cleanup.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related issues

  • #636: Directly addressed by this PR—adds userRes.ok check and error throw before parsing, matching the exact solution described in the issue.

Possibly related PRs

Suggested labels

quality:clean, level:beginner

Poem

🐰 A fetch that fails with grace so neat,
Now checks that ok is oh-so sweet!
No crashing 404s today,
The catch path clears the frown away. ✨

🚥 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 accurately describes the main change: adding HTTP response validation to the profile fetch logic, which is the primary focus of this bug fix.
Description check ✅ Passed The description includes all required template sections (Related Issue, Description, Testing, Type of Change) with adequate detail about the bug fix, testing approach, and issue closure.
Linked Issues check ✅ Passed The PR fully addresses issue #636 by implementing the exact solution proposed: adding an if (userRes.ok) check before parsing JSON to handle non-200 responses gracefully.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the HTTP status validation bug in the ContributorProfile component, with no out-of-scope 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.

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 Report: Improve HTTP Status Handling in Profile Fetch ⭐ RECOMMENDED

1 participant