Skip to content

fix(contributor): distinguish API errors from user not found#661

Open
mayurigade-hub wants to merge 2 commits into
GitMetricsLab:mainfrom
mayurigade-hub:fix/contributor-profile-error-handling
Open

fix(contributor): distinguish API errors from user not found#661
mayurigade-hub wants to merge 2 commits into
GitMetricsLab:mainfrom
mayurigade-hub:fix/contributor-profile-error-handling

Conversation

@mayurigade-hub
Copy link
Copy Markdown
Contributor

@mayurigade-hub mayurigade-hub commented Jun 1, 2026

Related Issue


Description

Improved error handling in ContributorProfile.tsx by separating "User not found" errors from other GitHub API failures.

Previously, all API failures (such as GitHub rate limits, network issues, or server errors) caused the page to display "User not found", which was misleading because the contributor may actually exist.

Changes made:

  • Added a dedicated error state for API failures
  • Show "User not found" only when GitHub returns a 404 response
  • Show a more accurate error message for API/network failures
  • Improved user feedback when contributor data cannot be loaded

How Has This Been Tested?

  • Opened a valid contributor profile and verified it loads correctly
  • Tested with an invalid GitHub username and verified "User not found" is displayed
  • Simulated GitHub API failures/network issues and verified a generic error message is shown instead of "User not found"
  • Confirmed no TypeScript or linting errors after the changes

Screenshots (if applicable)

N/A


Type of Change

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

Summary by CodeRabbit

Bug Fixes

  • Improved error handling for contributor profile lookups with distinct messages for "user not found" scenarios versus API/network failures
  • Enhanced error state management to provide clearer feedback when profile information is unavailable

@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 1, 2026

Deploy Preview for github-spy ready!

Name Link
🔨 Latest commit 63dfa82
🔍 Latest deploy log https://app.netlify.com/projects/github-spy/deploys/6a1d209f7c14540008487491
😎 Deploy Preview https://deploy-preview-661--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

Warning

Review limit reached

@mayurigade-hub, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 56 minutes and 49 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3fb02c0f-e841-4b7d-b118-05ed80fada7b

📥 Commits

Reviewing files that changed from the base of the PR and between a3e139b and 63dfa82.

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

Walkthrough

The PR adds error state tracking to distinguish "user not found" (404) errors from other API/network failures in the ContributorProfile component. Fetch logic now sets error type accordingly, and the render path returns different messages for each error case.

Changes

Error State Handling in Contributor Profile

Layer / File(s) Summary
Error state type and fetch/catch logic
src/pages/ContributorProfile/ContributorProfile.tsx
ErrorType state type introduced ("not_found" | "api_error"|null). Error state is reset at the start of each fetch, set to "not_found"for HTTP 404 responses, and set to"api_error"` for other failures and exceptions. Profile and prs are cleared on fetch failure.
Error render branches
src/pages/ContributorProfile/ContributorProfile.tsx
Render logic now includes two distinct early-return conditionals: one for "not_found" errors and one for "api_error" errors. Returns null when profile is missing instead of rendering a generic message.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • GitMetricsLab/github_tracker#623: Both PRs modify ContributorProfile.tsx's GitHub user fetch/catch flow to handle failed API responses and prevent crashes with appropriate error state rendering.
  • GitMetricsLab/github_tracker#484: Both PRs distinguish 404/not-found from other API errors in ContributorProfile.tsx and update profile/prs state handling accordingly.

Suggested labels

quality:clean, gssoc:approved, type:bug, level:beginner

Poem

A bug in the profile did lurk,
Showing "not found" as a quirk,
But when APIs fail, what's the tale?
Now clear messages won't derail,
Rabbit's fix makes error-handling work! 🐰

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: distinguishing API errors from user-not-found scenarios in contributor profile error handling.
Description check ✅ Passed The description follows the template structure with all required sections: Related Issue, Description, How Has This Been Tested, Type of Change, and includes clear explanations of the problem, solution, and testing performed.
Linked Issues check ✅ Passed The PR successfully addresses issue #629 by implementing separate error states: showing 'User not found' only for 404 responses and displaying a generic error message for other API/network failures.
Out of Scope Changes check ✅ Passed All changes are scoped to ContributorProfile.tsx and directly address the requirement to distinguish API errors from user-not-found scenarios; no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/pages/ContributorProfile/ContributorProfile.tsx`:
- Around line 32-33: The component resets error with setError(null) when
starting a new fetch but doesn't set loading to true; in the ContributorProfile
component locate the fetch-start blocks where setError(null) is called (the
initial fetch block and the second occurrence around the other fetch at the
referenced area) and add setLoading(true) before initiating the async request;
ensure the corresponding promise/finally handlers still call setLoading(false)
after completion so loading state is accurate during the fetch.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 28549b71-931a-4f73-907b-904b2f9e3e98

📥 Commits

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

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

Comment thread src/pages/ContributorProfile/ContributorProfile.tsx
@mayurigade-hub
Copy link
Copy Markdown
Contributor Author

Hello Maintainers
Please review this
Thank you!

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 Shows “User Not Found” for API Errors

1 participant