Repository navigation
π fix(web): read star history through GraphQL so the chart renders - #701
Conversation
GitHub's REST /stargazers endpoint now 401s without a token, and with a fine-grained token it demands contents=write β far more than a public star chart should hold. The route treated the token as optional, so every request fell through to the placeholder SVG and the README showed a permanently loading chart. Switch to the GraphQL stargazers connection, which needs only metadata=read and returns starredAt directly. A deployment without GITHUB_TOKEN still falls back rather than rendering an empty chart, since GraphQL has no anonymous mode.
The two REST-shaped assertions pinned batch.length < PER_PAGE and the exact fetch option order. Repoint them at the GraphQL pagination shape and add a case covering the endpoint swap and the no-token fallback.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@coderabbitai review |
|
Warning Review limit reached
Next review available in: 4 seconds You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review detailsβοΈ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: π Files selected for processing (2)
π WalkthroughWalkthroughThe star-history route now requires Possibly related PRs
π₯ Pre-merge checks | β 2β Passed checks (2 passed)
β¨ Finishing Touchesπ Generate docstrings
π§ͺ 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 |
|
β¦red regex CodeQL's js/regex/missing-regexp-anchor reads /https:\/\/api\.github\.com\/graphql/ as host matching that arbitrary hosts could straddle. The assertion only checks that the endpoint appears in the route source, so a plain includes() says the same thing without the pattern.
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 `@apps/web/src/app/api/star-history/route.ts`:
- Around line 88-111: In apps/web/src/app/api/star-history/route.ts lines
88-111, update the stargazer page validation to require boolean
pageInfo.hasNextPage, reject any edge without a valid string starredAt, and
return starredAt only when hasNextPage === false; continue pagination only when
it is true. In apps/web/scripts/marketing-performance.test.mjs lines 54-65,
replace the permissive pagination assertion with coverage confirming the route
rejects malformed pagination metadata.
πͺ Autofix
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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 0c6d6e23-0519-4c6d-bad7-b82f8dcbb1d8
π Files selected for processing (2)
apps/web/scripts/marketing-performance.test.mjsapps/web/src/app/api/star-history/route.ts
β¦al chart hasNextPage !== true read missing or non-boolean pagination metadata as the last page, and an unparseable starredAt was silently dropped. Either would cache a truncated series as the repo total for six hours. Require a boolean hasNextPage, fail the run on any edge without a parseable timestamp, and return the series only when hasNextPage is false. Reported by CodeRabbit on #701.
|
Fixed in a949996. The CodeQL anchor alert on the test file was fixed in 88095e8 β that assertion is a substring check now, and the |
biggest-littlest
left a comment
There was a problem hiding this comment.
GraphQL swap plus the strict page validation. Verified the chart renders.
What
The README star-history chart has been stuck on the placeholder ("loading") SVG. Root cause: GitHub's REST
/stargazersendpoint now returns 401 anonymously, and the route treatedGITHUB_TOKENas optional β sofetchStarredTimestamps()always returnedundefinedand the route permanently servedrenderStarHistoryFallbackSvg.Handing it a token doesn't fix it either: for a fine-grained token the endpoint reports
x-accepted-github-permissions: metadata=read; contents=write, and it 403s withmetadata=readalone. Grantingcontents=writeto a public star chart is not a trade worth making.Fix
Read the stargazers through GraphQL instead. That connection needs only
metadata=read, returnsstarredAtdirectly, and pages with a cursor. Verified live againstCodesWhat/drydock:Behaviour that did not change: every incomplete outcome still returns
undefinedand falls back rather than rendering a truncated total, the whole pagination run shares oneFETCH_DEADLINE_MSdeadline, and the success/failure cache headers are untouched. New: no token means fall back, since GraphQL has no anonymous mode.Verification
npx tsc --noEmitclean.npm run test:scripts --prefix apps/webβ 57/57. Two assertions pinned the REST pagination shape, so they're repointed at the GraphQL shape; added a case covering the endpoint swap and the no-token fallback.200, 7,578 bytes, real 216-star curve rendered β not the fallback.GITHUB_TOKENis set on thedrydock-websiteVercel project (production + preview) from a newdrydock-star-historyfine-grained token scoped toCodesWhat/drydockwith Metadata: Read-only.Changelog
starredAtordering and cursor pagination./stargazersto GraphQL.GITHUB_TOKENwithmetadata: read.contents: write.Concerns
coderabbitaireview after rate limiting ends.