fix: remove authError from useGitHubAuth destructure — always undefined#626
Conversation
✅ Deploy Preview for github-spy ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
📝 WalkthroughWalkthrough
ChangesError handling simplification
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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/Tracker/Tracker.tsx`:
- Around line 326-330: The Alert currently shows a generic dataError because
useGitHubData.fetchData uses Promise.allSettled and only sets a generic error
when hasRejected is true; update fetchData to inspect the settled results (the
rejected reasons) from Promise.allSettled, extract HTTP status or Octokit error
identifiers (e.g., 401/permissions), map those to specific auth messages, and
call setError(...) with the mapped message so dataError (rendered in
Tracker.tsx) shows auth-specific text; also confirm useGitHubAuth no longer
destructures authError and that setError is used instead of any removed
authError variable.
🪄 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: 5280b0f8-cfd6-4897-b949-b411edc8a994
📒 Files selected for processing (1)
src/pages/Tracker/Tracker.tsx
| {dataError && ( | ||
| <Alert severity="error" sx={{ mb: 3 }}> | ||
| {authError || dataError} | ||
| {dataError} | ||
| </Alert> | ||
| )} |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# 1) Confirm useGitHubAuth does NOT expose an `error` field (justifies the removal)
fd -t f 'useGitHubAuth.ts' --exec cat {}
# 2) Inspect useGitHubData: does it set `error` on 401/auth failures? Does fetchData
# handle a null octokit (missing token) without silently returning?
fd -t f 'useGitHubData.ts' --exec cat {}Repository: GitMetricsLab/github_tracker
Length of output: 6446
Tracker alert wiring: auth failures now reach dataError, but messaging is still generic
useGitHubAuthdoesn’t return anerrorfield, so removing the unusedauthErrordestructure is valid.useGitHubData.fetchDatawill surface auth failures to the Alert viasetError(...)when anyoctokit.requestpromise rejects (Promise.allSettled→hasRejected), so#625’s “show an alert” intent should work.- The more specific 401/permission messages in
useGitHubData’scatchlikely won’t run because request failures are handled byallSettled; consider extracting rejected reasons and mapping them to auth-specific messages to fully satisfy#625.
🤖 Prompt for 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.
In `@src/pages/Tracker/Tracker.tsx` around lines 326 - 330, The Alert currently
shows a generic dataError because useGitHubData.fetchData uses
Promise.allSettled and only sets a generic error when hasRejected is true;
update fetchData to inspect the settled results (the rejected reasons) from
Promise.allSettled, extract HTTP status or Octokit error identifiers (e.g.,
401/permissions), map those to specific auth messages, and call setError(...)
with the mapped message so dataError (rendered in Tracker.tsx) shows
auth-specific text; also confirm useGitHubAuth no longer destructures authError
and that setError is used instead of any removed authError variable.
|
🎉🎉 Thank you for your contribution! Your PR #626 has been merged! 🎉🎉 |
Related Issue
Tracker.tsx—authErroralwaysundefinedbecauseuseGitHubAuthdoes not expose anerrorfield #625Description
useGitHubAuthnever exposed anerrorfield, so destructuringerror: authErrorfrom it always resulted inauthErrorbeingundefined. This caused auth errors to be silently swallowed andnever displayed to the user.
error: authErrorfrom the destructuredataErrorHow Has This Been Tested?
useGitHubAuthreturn value — confirms noerrorfield existsdataErrormessage displays correctlyScreenshots (if applicable)
N/A
Type of Change
Summary by CodeRabbit