Skip to content

fix(topbar): handle GitHub API failure in getRepoStarCount#3483

Open
Nithin0620 wants to merge 3 commits intoresend:canaryfrom
Nithin0620:fix/repo-star-count-fallback
Open

fix(topbar): handle GitHub API failure in getRepoStarCount#3483
Nithin0620 wants to merge 3 commits intoresend:canaryfrom
Nithin0620:fix/repo-star-count-fallback

Conversation

@Nithin0620
Copy link
Copy Markdown

@Nithin0620 Nithin0620 commented May 7, 2026

What does this PR do?

Adds error handling to the getRepoStarCount function in topbar.tsx.

Previously, if the GitHub API was down, rate-limited, or returned an
unexpected response shape, the star count could display NaN or cause
an unhandled error.

Changes

  • Return '—' fallback when res.ok is false (rate limit / downtime)
  • Guard against undefined/NaN using typeof check instead of falsy check
  • Catch network failures and JSON parse errors silently

Before / After

Before: Star count shows NaN or crashes when GitHub API fails
After: Star count shows gracefully when GitHub API is unavailable

Checklist

  • No breaking changes
  • No new dependencies added
  • Tested locally

Summary by cubic

Handle GitHub API failures in the Topbar repo star count and avoid caching transient errors. getRepoStarCount now returns null for non-OK/invalid responses or parse failures, and the UI renders '—', preventing crashes or "NaN" while keeping the cache clean.

Written for commit a7ca384. Summary will update on new commits.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 7, 2026

⚠️ No Changeset found

Latest commit: a7ca384

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 7, 2026

@Nithin0620 is attempting to deploy a commit to the resend Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file

Confidence score: 4/5

  • This PR looks safe to merge with minimal risk: the reported issue is moderate (4/10) and limited to fallback behavior rather than a broad functional break.
  • In apps/web/src/components/topbar.tsx, returning the fallback in the revalidated fetch path could cache a transient GitHub outage as '—' for up to an hour, causing stale/misleading topbar data.
  • Pay close attention to apps/web/src/components/topbar.tsx - revalidation fallback handling may persist temporary upstream failures longer than intended.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/web/src/components/topbar.tsx">

<violation number="1" location="apps/web/src/components/topbar.tsx:14">
P2: Returning the fallback inside a revalidated fetch path can cache a transient GitHub failure as `'—'` for up to an hour.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread apps/web/src/components/topbar.tsx Outdated
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

0 issues found across 1 file (changes from recent commits).

Auto-approved: Low-risk defensive error handling in a non-critical UI component (GitHub star count). No business logic, database, or security impact. Changes are isolated and straightforward.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant