Skip to content

fix: avoid duplicate mock sponsors#918

Open
MoonBrillante wants to merge 2 commits into
TanStack:mainfrom
MoonBrillante:fix-duplicate-mock-sponsors
Open

fix: avoid duplicate mock sponsors#918
MoonBrillante wants to merge 2 commits into
TanStack:mainfrom
MoonBrillante:fix-duplicate-mock-sponsors

Conversation

@MoonBrillante

@MoonBrillante MoonBrillante commented May 13, 2026

Copy link
Copy Markdown
Contributor

Fixes #916

This updates the GitHub sponsors fallback data used when credentials are missing.

Previously, the mock sponsor list repeated the same sponsors 20 times each, which could make the sponsor graphic look like it contained many more unique sponsors than it actually did.

The fallback now keeps the same mock sponsors but returns each one only once.

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling for authentication failures with deterministic fallback mock sponsor data, ensuring consistent display behavior across requests

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Both getGithubSponsors implementations (src/server/sponsors.ts and src/utils/sponsors.functions.ts) replace the 401 error fallback: the old logic used flatMap to generate many duplicate entries with Math.random()-based amounts; the new logic maps a fixed 7-login array to sponsor objects with deterministic descending amount values.

Changes

Fix duplicate mock sponsors in 401 fallback

Layer / File(s) Summary
Replace random/duplicate 401 mock sponsors with deterministic list
src/server/sponsors.ts, src/utils/sponsors.functions.ts
Both files' 401 catch branches now build a fixed-login array of 7 entries and map each to a sponsor object with amount = mockSponsors.length - i, removing the previous flatMap duplication and Math.random() calls.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐇 A flatMap once cloned all my friends by the score,
With random amounts — what a duplicate bore!
Now seven unique ones stand proudly in line,
Descending by index, deterministic, fine.
No more phantom sponsors to make the list swell —
The bunny has fixed it, and all shall be well! 🌿

🚥 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing duplicate mock sponsors in the fallback data used when GitHub credentials fail.
Linked Issues check ✅ Passed The PR successfully addresses issue #916 by removing duplicate entries from mock sponsor fallback data, ensuring each sponsor appears only once.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing duplicate mock sponsors in the fallback data as specified in the linked issue, with no unrelated modifications.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/utils/sponsors.functions.ts (1)

222-230: 💤 Low value

Consider extracting the mock sponsor list to a shared constant.

The same mock sponsor array is defined in both src/utils/sponsors.functions.ts and src/server/sponsors.ts. While this duplication is low-risk for fallback data, extracting it to a shared constant would improve maintainability if the list needs updating in the future.

🤖 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/utils/sponsors.functions.ts` around lines 222 - 230, The mockSponsors
array is currently duplicated in two separate files. Extract this array to a
shared constant in a central utilities file or constants file that can be
imported by both locations, then update the mockSponsors definition in
sponsors.functions.ts and its duplicate in sponsors.ts to import and reference
this shared constant instead of maintaining separate copies.
🤖 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.

Nitpick comments:
In `@src/utils/sponsors.functions.ts`:
- Around line 222-230: The mockSponsors array is currently duplicated in two
separate files. Extract this array to a shared constant in a central utilities
file or constants file that can be imported by both locations, then update the
mockSponsors definition in sponsors.functions.ts and its duplicate in
sponsors.ts to import and reference this shared constant instead of maintaining
separate copies.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f57a377f-cbba-415b-9b7f-81a740a2e1d8

📥 Commits

Reviewing files that changed from the base of the PR and between 13f4d55 and 417b63c.

📒 Files selected for processing (2)
  • src/server/sponsors.ts
  • src/utils/sponsors.functions.ts

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.

Duplicate sponsors

1 participant