Skip to content

fix: remove authError from useGitHubAuth destructure — always undefined#626

Merged
mehul-m-prajapati merged 1 commit into
GitMetricsLab:mainfrom
ananyadarna:fix/auth-error-undefined
May 31, 2026
Merged

fix: remove authError from useGitHubAuth destructure — always undefined#626
mehul-m-prajapati merged 1 commit into
GitMetricsLab:mainfrom
ananyadarna:fix/auth-error-undefined

Conversation

@ananyadarna
Copy link
Copy Markdown
Contributor

@ananyadarna ananyadarna commented May 31, 2026

Related Issue


Description

useGitHubAuth never exposed an error field, so destructuring
error: authError from it always resulted in authError being
undefined. This caused auth errors to be silently swallowed and
never displayed to the user.

  • Removed error: authError from the destructure
  • Cleaned up the Alert block to rely only on dataError

How Has This Been Tested?

  • Verified useGitHubAuth return value — confirms no error field exists
  • Entered an invalid token and confirmed dataError message displays correctly
  • Entered a valid token and confirmed no error alert appears

Screenshots (if applicable)

N/A


Type of Change

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

Summary by CodeRabbit

  • Refactor
    • Simplified error handling in Tracker component. Error messages now display only for data-related issues, with the alert content derived directly from data errors.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 31, 2026

Deploy Preview for github-spy ready!

Name Link
🔨 Latest commit 3ac1e07
🔍 Latest deploy log https://app.netlify.com/projects/github-spy/deploys/6a1bc7ad5794670008a80526
😎 Deploy Preview https://deploy-preview-626--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 31, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

Tracker.tsx removes the unused authError variable that was always undefined because useGitHubAuth() does not expose an error field. The error alert UI is updated to display only dataError when present.

Changes

Error handling simplification

Layer / File(s) Summary
Remove unused authError and update error UI
src/pages/Tracker/Tracker.tsx
The useGitHubAuth() call no longer destructures error: authError, and the error alert condition is simplified from (authError || dataError) to dataError-only, with the alert body displaying dataError directly.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A hook that never had an error to give,
Was whispered about in the code that did live,
But now we've cleaned up what was never quite real,
Just dataError remains—the true deal! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: removing the undefined authError destructure from useGitHubAuth.
Description check ✅ Passed The description follows the template with all required sections complete, including related issue, detailed description of the bug fix, testing methodology, and type of change.
Linked Issues check ✅ Passed The PR directly addresses issue #625 by removing the non-existent authError destructure and ensuring auth errors are properly handled through dataError.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the authError bug in Tracker.tsx; no unrelated modifications are present.
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/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

📥 Commits

Reviewing files that changed from the base of the PR and between e7b8fc8 and 3ac1e07.

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

Comment on lines +326 to 330
{dataError && (
<Alert severity="error" sx={{ mb: 3 }}>
{authError || dataError}
{dataError}
</Alert>
)}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 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

  • useGitHubAuth doesn’t return an error field, so removing the unused authError destructure is valid.
  • useGitHubData.fetchData will surface auth failures to the Alert via setError(...) when any octokit.request promise rejects (Promise.allSettledhasRejected), so #625’s “show an alert” intent should work.
  • The more specific 401/permission messages in useGitHubData’s catch likely won’t run because request failures are handled by allSettled; 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.

@mehul-m-prajapati mehul-m-prajapati merged commit 5d8263d into GitMetricsLab:main May 31, 2026
7 checks passed
@github-actions
Copy link
Copy Markdown

🎉🎉 Thank you for your contribution! Your PR #626 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 Report: Tracker.tsxauthError always undefined because useGitHubAuth does not expose an error field

2 participants