Skip to content

πŸ› fix(web): read star history through GraphQL so the chart renders - #701

Merged
scttbnsn merged 4 commits into
dev/v1.6from
fix/star-history-graphql
Aug 12, 2026
Merged

scttbnsn merged 4 commits into
dev/v1.6from
fix/star-history-graphql

Conversation

@scttbnsn

@scttbnsn scttbnsn commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

What

The README star-history chart has been stuck on the placeholder ("loading") SVG. Root cause: GitHub's REST /stargazers endpoint now returns 401 anonymously, and the route treated GITHUB_TOKEN as optional β€” so fetchStarredTimestamps() always returned undefined and the route permanently served renderStarHistoryFallbackSvg.

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 with metadata=read alone. Granting contents=write to a public star chart is not a trade worth making.

Fix

Read the stargazers through GraphQL instead. That connection needs only metadata=read, returns starredAt directly, and pages with a cursor. Verified live against CodesWhat/drydock:

{"data":{"repository":{"stargazerCount":216,"stargazers":{"edges":[{"starredAt":"2026-02-10T16:53:13Z"},...]}}}}

Behaviour that did not change: every incomplete outcome still returns undefined and falls back rather than rendering a truncated total, the whole pagination run shares one FETCH_DEADLINE_MS deadline, and the success/failure cache headers are untouched. New: no token means fall back, since GraphQL has no anonymous mode.

Verification

  • npx tsc --noEmit clean.
  • 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.
  • Ran the route against a real token on a local dev server: 200, 7,578 bytes, real 216-star curve rendered β€” not the fallback.

GITHUB_TOKEN is set on the drydock-website Vercel project (production + preview) from a new drydock-star-history fine-grained token scoped to CodesWhat/drydock with Metadata: Read-only.

Changelog

  • ✨ Added GraphQL stargazer queries with starredAt ordering and cursor pagination.
  • πŸ”§ Changed the star-history route from REST /stargazers to GraphQL.
  • πŸ”§ Changed authentication to require GITHUB_TOKEN with metadata: read.
  • πŸ› Fixed fallback handling for missing tokens, invalid responses, incomplete pagination, and pagination limits.
  • πŸ”’ Removed dependence on the REST endpoint, which requires contents: write.
  • ✨ Added tests for GraphQL requests, pagination, REST endpoint exclusion, and no-token fallback.

Concerns

  • Confirm the pagination limit matches the maximum expected repository star count.
  • Complete the coderabbitai review after rate limiting ends.

Test added 2 commits August 11, 2026 22:43
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.
@vercel

vercel Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
drydock-website Ready Ready Preview Aug 12, 2026 3:44am
drydockdemo-website Ready Ready Preview Aug 12, 2026 3:44am

@scttbnsn

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@scttbnsn, you've reached your PR review limit, so we couldn't start this review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3e78873f-a939-4a2e-bdbe-bef10cfd86fd

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 88095e8 and a949996.

πŸ“’ Files selected for processing (2)
  • apps/web/scripts/marketing-performance.test.mjs
  • apps/web/src/app/api/star-history/route.ts
πŸ“ Walkthrough

Walkthrough

The star-history route now requires GITHUB_TOKEN and uses GitHub GraphQL cursor pagination. It requests ascending starredAt edges, validates response data, and returns undefined for incomplete pagination or invalid inputs. Tests cover final-page completion, missing tokens, malformed edges, GraphQL ordering, REST endpoint exclusion, abort signals, and request options.

Possibly related PRs

πŸš₯ Pre-merge checks | βœ… 2
βœ… Passed checks (2 passed)
Check name Status Explanation
Linked Issues check βœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check βœ… Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
πŸ“ Generate docstrings
  • Create stacked PR
  • Commit on current branch
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/star-history-graphql

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.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

…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.

@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.

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

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between daf1229 and 88095e8.

πŸ“’ Files selected for processing (2)
  • apps/web/scripts/marketing-performance.test.mjs
  • apps/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.
@scttbnsn

Copy link
Copy Markdown
Contributor Author

Fixed in a949996. hasNextPage must now be an actual boolean, any edge without a parseable starredAt fails the whole run, and the series returns only on hasNextPage === false. Tests updated to assert the strict shape instead of the permissive one. Re-verified live against the real token: 200, real 216-star curve, no fallback.

The CodeQL anchor alert on the test file was fixed in 88095e8 β€” that assertion is a substring check now, and the CodeQL check is green.

@biggest-littlest biggest-littlest left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

GraphQL swap plus the strict page validation. Verified the chart renders.

@ALARGECOMPANY ALARGECOMPANY left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

@scttbnsn
scttbnsn merged commit 3881965 into dev/v1.6 Aug 12, 2026
25 of 26 checks passed
@scttbnsn
scttbnsn deleted the fix/star-history-graphql branch August 12, 2026 04:03

This branch was successfully deployed

2 active deployments
Preview – drydockdemo-website β€” a949996c Deployed Aug 12, 2026 by vercel[bot]
Preview – drydock-website β€” a949996c Deployed Aug 12, 2026 by vercel[bot]
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.

4 participants